Last active
January 20, 2017 10:05
-
-
Save mattiasostmar/00d99a935923b32ed6b6bca1b5029165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pywikibot | |
from pywikibot import pagegenerators as pg | |
site = pywikibot.Site(fam="commons") | |
cat = pywikibot.Category(site, 'Category:Media_from_the_National_Museums_of_World_Culture') | |
gen = pg.CategorizedPageGenerator(cat) | |
for page in gen: | |
filePage = pywikibot.FilePage(page) | |
try: | |
# Do something... E.g. add template for speedy deletion | |
filePage.text = "{{speedydelete|broken file upload}}\n" + current | |
filePage.save("Add template for speedy deletion due to no image uploaded, only text") | |
except pywikibot.exceptions.PageRelatedError as e: # normally means there's no such page | |
print("{} seems to not exist on Commons".format(filePage) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment