* Images: fixed images download of special or promo cards without english version (example: Mysterious Egg, see #6829);

This commit is contained in:
Oleg Agafonov 2020-07-11 06:35:55 +04:00
parent 165d7362b0
commit 656e4304ae
2 changed files with 14 additions and 1 deletions

View file

@ -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);
}
}

View file

@ -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);