2
0
mirror of https://github.com/WikiTeam/wikiteam synced 2024-11-10 13:10:27 +00:00

Fallback to scraper if API allpages disabled

This commit is contained in:
PiRSquared17 2014-09-23 15:49:57 -04:00
parent 40c406cd00
commit 757019521a

View File

@ -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)