* Images: fixed broken download of some promo double faces cards (#7891);

This commit is contained in:
Oleg Agafonov 2021-07-01 16:37:57 +04:00
parent d7a93cc95f
commit 4b6fae663f
3 changed files with 24 additions and 6 deletions

View file

@ -125,13 +125,30 @@ public enum ScryfallImageSource implements CardImageSource {
final String defaultCode = CardLanguage.ENGLISH.getCode();
final String localizedCode = languageAliases.getOrDefault(this.getCurrentLanguage(), defaultCode);
// licalized and default
List<String> needUrls = new ArrayList<>();
needUrls.add("https://api.scryfall.com/cards/"
+ formatSetName(card.getSet(), isToken) + "/" + card.getCollectorId() + "/" + localizedCode);
if (!localizedCode.equals(defaultCode)) {
String apiUrl = ScryfallImageSupportCards.findDirectDownloadLink(card.getSet(), card.getName(), card.getCollectorId());
if (apiUrl != null) {
// BY DIRECT URL
// direct links via hardcoded API path. Used for cards with non-ASCII collector numbers
if (localizedCode.equals(defaultCode)) {
// english only, so can use workaround without loc param (scryfall download first available card)
// workaround to use cards without english images (some promos or special cards)
needUrls.add(apiUrl);
} else {
// localize, must use loc params
needUrls.add(apiUrl + localizedCode);
needUrls.add(apiUrl + defaultCode);
}
} else {
// BY CARD NUMBER
// localized and default
needUrls.add("https://api.scryfall.com/cards/"
+ formatSetName(card.getSet(), isToken) + "/" + card.getCollectorId() + "/" + defaultCode);
+ formatSetName(card.getSet(), isToken) + "/" + card.getCollectorId() + "/" + localizedCode);
if (!localizedCode.equals(defaultCode)) {
needUrls.add("https://api.scryfall.com/cards/"
+ formatSetName(card.getSet(), isToken) + "/" + card.getCollectorId() + "/" + defaultCode);
}
}
InputStream jsonStream = null;

View file

@ -523,6 +523,7 @@ public class ScryfallImageSupportCards {
// Cards with non-ASCII collector numbers must use direct download (cause xmage uses different card number)
// Verify checks must check and show missing data from that list
// WARNING, must use as API link, not image
// 10E
put("10E/Air Elemental/64*", "https://api.scryfall.com/cards/10e/64★/");
put("10E/Anaba Bodyguard/187*", "https://api.scryfall.com/cards/10e/187★/");

View file

@ -37,7 +37,7 @@ public final class Portal extends ExpansionSet {
cards.add(new SetCardInfo("Armageddon", 5, Rarity.RARE, mage.cards.a.Armageddon.class));
cards.add(new SetCardInfo("Armored Pegasus", 6, Rarity.COMMON, mage.cards.a.ArmoredPegasus.class));
cards.add(new SetCardInfo("Arrogant Vampire", 79, Rarity.UNCOMMON, mage.cards.a.ArrogantVampire.class));
cards.add(new SetCardInfo("Assassin's Blade", "80a", Rarity.COMMON, mage.cards.a.AssassinsBlade.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Assassin's Blade", "80s", Rarity.COMMON, mage.cards.a.AssassinsBlade.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Assassin's Blade", 80, Rarity.UNCOMMON, mage.cards.a.AssassinsBlade.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Balance of Power", 41, Rarity.RARE, mage.cards.b.BalanceOfPower.class));
cards.add(new SetCardInfo("Baleful Stare", 42, Rarity.UNCOMMON, mage.cards.b.BalefulStare.class));