From 757019521a354811629333387880f97270540600 Mon Sep 17 00:00:00 2001 From: PiRSquared17 Date: Tue, 23 Sep 2014 15:49:57 -0400 Subject: [PATCH] Fallback to scraper if API allpages disabled --- dumpgenerator.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dumpgenerator.py b/dumpgenerator.py index b8a77ca..4040ad0 100644 --- a/dumpgenerator.py +++ b/dumpgenerator.py @@ -326,7 +326,13 @@ def getPageTitles(config={}, session=None): titles = [] if 'api' in config and config['api']: - titles = getPageTitlesAPI(config=config, session=session) + r = session.post(config['api'], {'action': 'query', 'list': 'allpages', 'format': 'json'}) + test = json.loads(r.text) + if ('warnings' in test and 'allpages' in test['warnings'] and '*' in test['warnings']['allpages'] + and test['warnings']['allpages']['*'] == 'The "allpages" module has been disabled.'): + titles = getPageTitlesScraper(config=config, session=session) + else: + titles = getPageTitlesAPI(config=config, session=session) elif 'index' in config and config['index']: titles = getPageTitlesScraper(config=config, session=session)