mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
images: added normal images size download from scryfall source - 2/3 of BIG sizes but with same quality (#12450)
This commit is contained in:
parent
11bd8c29b2
commit
b0f08d278f
2 changed files with 51 additions and 0 deletions
|
|
@ -0,0 +1,50 @@
|
|||
package org.mage.plugins.card.dl.sources;
|
||||
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author tiera3
|
||||
*/
|
||||
public class ScryfallImageSourceNormal extends ScryfallImageSource {
|
||||
|
||||
private static final ScryfallImageSourceNormal instanceNormal = new ScryfallImageSourceNormal();
|
||||
|
||||
public static ScryfallImageSource getInstance() {
|
||||
return instanceNormal;
|
||||
}
|
||||
|
||||
private static String innerModifyUrlString(String oneUrl) {
|
||||
return oneUrl.replaceFirst("/large/","/normal/").replaceFirst("format=image","format=image&version=normal");
|
||||
}
|
||||
|
||||
private static CardImageUrls innerModifyUrl(CardImageUrls cardUrls) {
|
||||
List<String> downloadUrls = cardUrls.getDownloadList().stream()
|
||||
.map(ScryfallImageSourceNormal::innerModifyUrlString)
|
||||
.collect(Collectors.toList());
|
||||
return new CardImageUrls(downloadUrls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourceName() {
|
||||
return "scryfall.com - normal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardImageUrls generateCardUrl(CardDownloadData card) throws Exception {
|
||||
return innerModifyUrl(super.generateCardUrl(card));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardImageUrls generateTokenUrl(CardDownloadData card) throws Exception {
|
||||
return innerModifyUrl(super.generateTokenUrl(card));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAverageSize() {
|
||||
return 100; // initial estimate - TODO calculate a more accurate number
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -77,6 +77,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
|||
WIZARDS("1. wizards.com - low quality, cards only, multi-language", WizardCardsImageSource.instance),
|
||||
SCRYFALL_BIG("2a. scryfall.com - BIG: high quality, multi-language", ScryfallImageSource.getInstance()),
|
||||
SCRYFALL_SMALL("2b. scryfall.com - small: low quality, multi-language", ScryfallImageSourceSmall.getInstance()),
|
||||
SCRYFALL_NORM("2c. scryfall.com - normal: good quality, multi-language", ScryfallImageSourceNormal.getInstance()),
|
||||
GRAB_BAG("3. GrabBag - unofficial STAR WARS cards and tokens", GrabbagImageSource.instance),
|
||||
COPYPASTE("4. Experimental - copy and paste image URLs", CopyPasteImageSource.instance); // TODO: need rework for user friendly GUI
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue