mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Images: fixed images download of special or promo cards without english version (example: Mysterious Egg, see #6829);
This commit is contained in:
parent
165d7362b0
commit
656e4304ae
2 changed files with 14 additions and 1 deletions
|
@ -2,6 +2,7 @@ package org.mage.plugins.card.dl.sources;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JayDi85
|
* @author JayDi85
|
||||||
|
@ -25,7 +26,10 @@ public class CardImageUrls {
|
||||||
|
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
|
|
||||||
if (alternativeUrl != null && !alternativeUrl.isEmpty()) {
|
if (alternativeUrl != null
|
||||||
|
&& alternativeUrl != null
|
||||||
|
&& !alternativeUrl.isEmpty()
|
||||||
|
&& !Objects.equals(baseUrl, alternativeUrl)) {
|
||||||
this.alternativeUrls.add(alternativeUrl);
|
this.alternativeUrls.add(alternativeUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,15 @@ public enum ScryfallImageSource implements CardImageSource {
|
||||||
+ card.getCollectorId() + "/" + localizedCode + "?format=image";
|
+ card.getCollectorId() + "/" + localizedCode + "?format=image";
|
||||||
alternativeUrl = "https://api.scryfall.com/cards/" + formatSetName(card.getSet(), isToken) + "/"
|
alternativeUrl = "https://api.scryfall.com/cards/" + formatSetName(card.getSet(), isToken) + "/"
|
||||||
+ card.getCollectorId() + "/" + defaultCode + "?format=image";
|
+ 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);
|
return new CardImageUrls(baseUrl, alternativeUrl);
|
||||||
|
|
Loading…
Reference in a new issue