-
-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add _substr_[pos]_[len] to picture download templates #4762
Conversation
in my testing using this template url works great and is 3 times faster because it avoids any redirects: |
SF discourages direct CDN links as they're not guaranteed to be consistent over time. I just worry this could cause us headaches in the future if they change their folder structures |
I'm not advocating setting this as the default option, I'm just enabling the option by adding a broadly applicable template option. |
What I was thinking in #4756 (comment) was rather along the lines to add |
that would overrule users' configured download url templates, I can see something like that implemented with #4109 instead (this would replace oracle) |
Right, picURL is tried first, not last, I got confused. |
the goal of this pr isn't the subversion of scyfall's api, it simply expands the url template language |
Would it be an option to actually make this the default to prevent any issues with rate limits, but leave the API still in there in case that they change something on their end?
|
changing the default url templates is out of scope for this pr. this is possible but would mean we'd need to do an update to the application if they would change this template, we could do a similar approach to the default server list though and have this default be downloaded. |
This PR accomplishes its goal of expanding the ops of the language. I agree with no making this a default. Seems fine to go. |
Related Ticket(s)
Short roundup of the initial problem
this comment mentions the option for us to skip using the scryfall api by going for the card image location directly: #4756 (comment)
scryfall card cdn uses urls with this format:
cards.scryfall.io/[card size]/[card face]/[first hex of id]/[second hex of id]/[complete id].jpg?[unix timestamp of update]
this format is mostly compatible with our url formatting except for the option to get parts of the id instead of the full id. if we were to allow getting parts of the id in our formatting template we'd be able to use this template to download directly from the cdn without going through the api:
https://cards.scryfall.io/large/!prop:side!/!set:uuid_substr_0_1!/!set:uuid_substr_1_1!/!set:uuid!.jpg?latest
scryfall's policy is a bit unclear on this, on one hand they don't seem to encourage doing this in case the url is inaccurate but on the other hand they wouldn't mind not spending bandwidth on a request I'd guess.
getting the timestamp of the last update is not possible for us without using the api, storing this information seems a bit pointless as it can change after oracle has run. the timestamp is optional and afaik is used to force the cdn to fetch the most recently updated version as their aws will have cached versions of the image on multiple worldwide instances, changing the url forces it to update the cache, if this is the case the effects of not including the timestamp are limited. randomising this extra bit to the url (or using the current time for it) is a bad idea and will pretty much break #4756 as well. instead we could use some other identifier that is unique to that client, like the clientid, it doesn't seem worth it though. if this is a concern we should instead focus on the client having this exact same issue first, as the client will not download new images if it's on its own disk cache.
What will change with this Pull Request?
_substr_[pos]_[len]
to the picture loader, note that it applies before _fill_with