From 656e4304ae1e8a22d28377830ab65a567221f985 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 11 Jul 2020 06:35:55 +0400 Subject: [PATCH] * Images: fixed images download of special or promo cards without english version (example: Mysterious Egg, see #6829); --- .../org/mage/plugins/card/dl/sources/CardImageUrls.java | 6 +++++- .../plugins/card/dl/sources/ScryfallImageSource.java | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageUrls.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageUrls.java index 1176ad3fed..e27a002cee 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageUrls.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageUrls.java @@ -2,6 +2,7 @@ package org.mage.plugins.card.dl.sources; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author JayDi85 @@ -25,7 +26,10 @@ public class CardImageUrls { this.baseUrl = baseUrl; - if (alternativeUrl != null && !alternativeUrl.isEmpty()) { + if (alternativeUrl != null + && alternativeUrl != null + && !alternativeUrl.isEmpty() + && !Objects.equals(baseUrl, alternativeUrl)) { this.alternativeUrls.add(alternativeUrl); } } 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 a3e4e15055..350b79eb94 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 @@ -119,6 +119,15 @@ public enum ScryfallImageSource implements CardImageSource { + card.getCollectorId() + "/" + localizedCode + "?format=image"; alternativeUrl = "https://api.scryfall.com/cards/" + formatSetName(card.getSet(), isToken) + "/" + card.getCollectorId() + "/" + defaultCode + "?format=image"; + + // workaround to use cards without english images (some promos or special cards) + // bug: https://github.com/magefree/mage/issues/6829 + // example: Mysterious Egg from IKO https://api.scryfall.com/cards/iko/385/?format=image + if (Objects.equals(baseUrl, alternativeUrl)) { + // without loc code scryfall must return first available image + alternativeUrl = "https://api.scryfall.com/cards/" + formatSetName(card.getSet(), isToken) + "/" + + card.getCollectorId() + "/?format=image"; + } } return new CardImageUrls(baseUrl, alternativeUrl);