From 4b6fae663f6d2b6b9c7ce387aac9b0031d30985e Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Thu, 1 Jul 2021 16:37:57 +0400 Subject: [PATCH] * Images: fixed broken download of some promo double faces cards (#7891); --- .../card/dl/sources/ScryfallImageSource.java | 27 +++++++++++++++---- .../dl/sources/ScryfallImageSupportCards.java | 1 + Mage.Sets/src/mage/sets/Portal.java | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java index 547b8d3e7c..96fcb74f8d 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java @@ -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 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; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSupportCards.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSupportCards.java index cd71706e86..3b3a862929 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSupportCards.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSupportCards.java @@ -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★/"); diff --git a/Mage.Sets/src/mage/sets/Portal.java b/Mage.Sets/src/mage/sets/Portal.java index 94549e9b6f..ca5634f30e 100644 --- a/Mage.Sets/src/mage/sets/Portal.java +++ b/Mage.Sets/src/mage/sets/Portal.java @@ -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));