diff options
Diffstat (limited to 'proposals.py')
-rwxr-xr-x | proposals.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/proposals.py b/proposals.py index 3ecc962..dc770b4 100755 --- a/proposals.py +++ b/proposals.py @@ -5,6 +5,7 @@ import sys import pywikiapi import mwparserfromhell +import requests OSMWIKI_ENDPOINT = 'https://wiki.openstreetmap.org/w/api.php' @@ -12,6 +13,11 @@ osmwiki = pywikiapi.Site(OSMWIKI_ENDPOINT) # https://wiki.openstreetmap.org/w/index.php?title=Template:Proposal_page&action=edit +res = requests.get( + 'https://wiki.openstreetmap.org/w/api.php?action=expandtemplates&prop=wikitext&format=json&text={%7B%23invoke:languages/table%7Cjson}}' +) +langs = json.loads(res.json()['expandtemplates']['wikitext']) + def get_template_val(tpl, name): param = tpl.get(name, None) @@ -110,9 +116,17 @@ for page in osmwiki.query_pages( definition = get_template_val(tpl, 'definition') users = get_template_val(tpl, 'users') or get_template_val(tpl, 'user') + parts = page_title.split(':', maxsplit=1) + parts[0] = parts[0].lower() + + lang = None + if parts[0] in langs: + lang = parts[0] + proposals.append( dict( page_title=page_title, + lang=lang, name=name, status=status, definition=definition, |