Merge branch '88-crash-on-fetching-image-information' into 'testing'

Resolve "Crash on fetching image information"

See merge request piotrex43/RcGcDw!52
This commit is contained in:
Frisk 2019-06-11 17:31:56 +00:00
commit d6e56fb18b

View file

@ -508,12 +508,16 @@ def embed_formatter(action, change, parsed_comment, categories):
if action == "upload/overwrite": if action == "upload/overwrite":
if additional_info_retrieved: if additional_info_retrieved:
article_encoded = change["title"].replace(" ", "_").replace(')', '\)') article_encoded = change["title"].replace(" ", "_").replace(')', '\)')
img_timestamp = [x for x in img_info[1]["timestamp"] if x.isdigit()] try:
undolink = "https://{wiki}.gamepedia.com/index.php?title={filename}&action=revert&oldimage={timestamp}%21{filenamewon}".format( img_timestamp = [x for x in img_info[1]["timestamp"] if x.isdigit()]
wiki=settings["wiki"], filename=article_encoded, timestamp="".join(img_timestamp), except IndexError:
filenamewon=article_encoded.split(":", 1)[1]) logger.exception("Could not analize the information about the image (does it have only one version when expected more in overwrite?) which resulted in no Options field: {}".format(img_info))
embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}) | [undo]({undolink}))").format( else:
link=embed["image"]["url"], undolink=undolink)}] undolink = "https://{wiki}.gamepedia.com/index.php?title={filename}&action=revert&oldimage={timestamp}%21{filenamewon}".format(
wiki=settings["wiki"], filename=article_encoded, timestamp="".join(img_timestamp),
filenamewon=article_encoded.split(":", 1)[1])
embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}) | [undo]({undolink}))").format(
link=embed["image"]["url"], undolink=undolink)}]
embed["title"] = _("Uploaded a new version of {name}").format(name=change["title"]) embed["title"] = _("Uploaded a new version of {name}").format(name=change["title"])
else: else:
embed["title"] = _("Uploaded {name}").format(name=change["title"]) embed["title"] = _("Uploaded {name}").format(name=change["title"])