mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00:00
Add scryfall.com as a source for card images (closes #3496).
This commit is contained in:
parent
9a465bf523
commit
0c9c7c0a56
2 changed files with 83 additions and 1 deletions
|
@ -0,0 +1,78 @@
|
|||
package org.mage.plugins.card.dl.sources;
|
||||
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Quercitron
|
||||
*
|
||||
*/
|
||||
public enum ScryfallImageSource implements CardImageSource {
|
||||
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public String generateURL(CardDownloadData card) throws Exception {
|
||||
return "https://api.scryfall.com/cards/" + formatSetName(card.getSet()) + "/" + card.getCollectorId() + "?format=image";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateTokenUrl(CardDownloadData card) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNextHttpImageUrl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileForHttpImage(String httpImageUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourceName() {
|
||||
return "scryfall.com";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAverageSize() {
|
||||
return 240;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalImages() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTokenSource() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPause(String httpImageUrl) {
|
||||
|
||||
}
|
||||
|
||||
private String formatSetName(String setName) {
|
||||
if (setNameReplacement.containsKey(setName)) {
|
||||
setName = setNameReplacement.get(setName);
|
||||
}
|
||||
return setName.toLowerCase();
|
||||
}
|
||||
|
||||
private static final Map<String, String> setNameReplacement = new HashMap<String, String>() {
|
||||
{
|
||||
put("DD3GVL", "gvl");
|
||||
put("DD3JVC", "jvc");
|
||||
put("DD3DVD", "dvd");
|
||||
put("DD3EVG", "evg");
|
||||
put("MPS-AKH", "mp2");
|
||||
put("MBP", "pmei");
|
||||
}
|
||||
};
|
||||
}
|
|
@ -110,7 +110,8 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
"mtg.onl",
|
||||
"alternative.mtg.onl",
|
||||
"GrabBag",
|
||||
"magidex.com"
|
||||
"magidex.com",
|
||||
"scryfall.com",
|
||||
//"mtgathering.ru HQ",
|
||||
//"mtgathering.ru MQ",
|
||||
//"mtgathering.ru LQ",
|
||||
|
@ -148,6 +149,9 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
case 7:
|
||||
cardImageSource = MagidexImageSource.instance;
|
||||
break;
|
||||
case 8:
|
||||
cardImageSource = ScryfallImageSource.instance;
|
||||
break;
|
||||
}
|
||||
updateCardsToDownload();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue