Currently we have a loosely-defined image url download priority order with fallback.
The goal of this ticket is to come up with a flexible, understandable design that helps users get the images they want.
At a high level, we currently have:
if card has muid:
I propose instead:
When a card image is requested:
In pseudocode:
QList<UrlTemplate> urls = get_urls_for_card(cardInfo, enabledSetConfiguration);
for (UrlTemplate url, urls):
Url url = UrlTemplate.apply(cardInfo)
response = download(url)
if response.ok:
save(response.image)
else:
continue
This ticket supersedes #1984 and #2346
FYI I'm going to take a look at this (so multiple people aren't working on the same thing). The first thing I'd like to do is just take the 2 existing URLs and fall back as expected: On 404 for the first one, (instead of muid of card), going by set in priority order.
The list of multiple URLs by priority could come in a later PR. No idea how long I expect it to take.
@andrewzwicky come grab us in gitter if you get stuck! This is exciting :)
I have something tentatively working, here's a log in action.
Trying to load picture for card: "Angelic Benediction" from set: "DD3_DVD"
Picture not found, trying to download
Trying to download picture for card: "Angelic Benediction" from set: "DD3_DVD" from url: "http://magiccards.info/scans/en/dd3_dvd/19.jpg"
following redirect: "Angelic Benediction" Url: "https://magiccards.info/scans/en/dd3_dvd/19.jpg"
Download failed: "Error transferring https://magiccards.info/scans/en/dd3_dvd/19.jpg - server replied: Not Found"
Possible picture at "https://magiccards.info/scans/en/dd3_dvd/19.jpg" could not be loaded
Trying to load picture for card: "Angelic Benediction" from set: "DD3_DVD"
Picture not found, trying to download
Trying to download picture for card: "Angelic Benediction" from set: "DD3_DVD" from url: "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=394008&type=deck"
Possible picture at "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=394008&type=deck" could not be loaded
Trying to load picture for card: "Angelic Benediction" from set: "M13"
Picture not found, trying to download
Trying to download picture for card: "Angelic Benediction" from set: "M13" from url: "http://magiccards.info/scans/en/m13/4.jpg"
following redirect: "Angelic Benediction" Url: "https://magiccards.info/scans/en/m13/4.jpg"
Image successfully downloaded from "https://magiccards.info/scans/en/m13/4.jpg"
This is using:
http://magiccards.info/scans/en/!setcode_lower!/!setnumber!.jpg as my primary URL and http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=deck as my secondary URL, (with =deck on the end, so it will intentionally fail).
For the set that doesn't match, the download is attempted, but then it moves the secondary URL, then to the next set. Code needs to be cleaned up and tested more thoroughly, but it's looking good so far.
@andrewzwicky awesome! Do you want to open a WIP PR for any early feedback?
@Daenyth Yeah that's a good idea, I'll do that.
Most helpful comment
FYI I'm going to take a look at this (so multiple people aren't working on the same thing). The first thing I'd like to do is just take the 2 existing URLs and fall back as expected: On 404 for the first one, (instead of muid of card), going by set in priority order.
The list of multiple URLs by priority could come in a later PR. No idea how long I expect it to take.