From de10e560c35bb0d29457e039f574e1195b25dbde Mon Sep 17 00:00:00 2001 From: "E.zn" Date: Thu, 2 Apr 2020 01:23:53 +0200 Subject: [PATCH] populate_creator_pages.py --- populate_creator_pages.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 populate_creator_pages.py diff --git a/populate_creator_pages.py b/populate_creator_pages.py new file mode 100644 index 0000000..f3f47c8 --- /dev/null +++ b/populate_creator_pages.py @@ -0,0 +1,25 @@ +import os, argparse, sys, re, json +from mwclient import (Site, + errors) + +# API CALL +# https://hub.xpub.nl/sandbox/itchwiki/api.php?action=smwbrowse&browse=pvalue¶ms={ "limit": 1500, "offset": 0, "property" : "Creator", "search": "" }&format=json +# generated orgs.json + +# login +site = Site(host='hub.xpub.nl/sandbox', path='/itchwiki/') + +wd =os.path.dirname(os.path.abspath(__file__)) # parent working directory +with open(os.path.join(wd, 'login.txt'), 'r') as login: # read login user & pwd + loginlines = login.read() + user, pwd = loginlines.split('\n') + site.login(username=user, password=pwd) # login to wiki + + +with open('creators.json', 'r') as f: + creators = json.load(f) + +for pagename in creators['query']: + page = site.pages[pagename] + print(pagename) + page.save(page.text() + '\n[[Category:Creator]]')