Browse Source

Fix backgrounds when the image has been moved.

pull/24/head
Ben Kurtovic 9 years ago
parent
commit
1327f57404
1 changed files with 6 additions and 8 deletions
  1. +6
    -8
      copyvios/background.py

+ 6
- 8
copyvios/background.py View File

@@ -19,14 +19,12 @@ def _get_commons_site():
return cache.bot.wiki.add_site(project="wikimedia", lang="commons")

def _load_file(site, filename):
res = site.api_query(action="query", prop="imageinfo", iiprop="url|size",
titles="File:" + filename)
data = res["query"]["pages"].values()[0]["imageinfo"][0]
url = data["url"]
descurl = data["descriptionurl"]
width = data["width"]
height = data["height"]
return filename.replace(" ", "_"), url, descurl, width, height
data = site.api_query(
action="query", prop="imageinfo", iiprop="url|size|canonicaltitle",
titles="File:" + filename)
res = data["query"]["pages"].values()[0]["imageinfo"][0]
name = res["canonicaltitle"][len("File:"):].replace(" ", "_")
return name, res["url"], res["descriptionurl"], res["width"], res["height"]

def _get_fresh_potd():
site = _get_commons_site()


Loading…
Cancel
Save