From 1327f57404fd6c429e81c69913f77beac9591d65 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 4 Jun 2015 18:58:19 -0400 Subject: [PATCH] Fix backgrounds when the image has been moved. --- copyvios/background.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/copyvios/background.py b/copyvios/background.py index bae8708..753cef9 100644 --- a/copyvios/background.py +++ b/copyvios/background.py @@ -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()