Some updates to image download.

This commit is contained in:
LevelX2 2017-09-15 23:18:40 +02:00
parent a280605591
commit 3fc3d96fe0
4 changed files with 29 additions and 6 deletions

View file

@ -376,4 +376,10 @@ public enum MtgOnlTokensImageSource implements CardImageSource {
@Override
public void doPause(String httpImageUrl) {
}
@Override
public boolean isImageProvided(String setCode, String cardName) {
return true;
}
}

View file

@ -34,8 +34,10 @@ import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import org.apache.log4j.Logger;
import org.mage.plugins.card.images.CardDownloadData;
@ -53,6 +55,11 @@ public enum TokensMtgImageSource implements CardImageSource {
private HashMap<String, ArrayList<TokenData>> tokensData;
private final Object tokensDataSync = new Object();
private final Set<String> supportedSets;
private TokensMtgImageSource() {
this.supportedSets = new LinkedHashSet<>();
}
@Override
public String getSourceName() {
@ -201,6 +208,7 @@ public enum TokensMtgImageSource implements CardImageSource {
List<TokenData> siteTokensData = parseTokensData(inputStream);
for (TokenData siteData : siteTokensData) {
String key = siteData.getExpansionSetCode() + "/" + siteData.getName();
supportedSets.add(siteData.getExpansionSetCode());
ArrayList<TokenData> list = tokensData.get(key);
if (list == null) {
list = new ArrayList<>();
@ -335,4 +343,10 @@ public enum TokensMtgImageSource implements CardImageSource {
return false;
}
@Override
public ArrayList<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>();
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
}
}

View file

@ -81,12 +81,12 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
WIZARDS("wizards.com", WizardCardsImageSource.instance),
MYTHICSPOILER("mythicspoiler.com", MythicspoilerComSource.instance),
TOKENS("tokens.mtg.onl", TokensMtgImageSource.instance),
MTG_ONL("mtg.onl", MtgOnlTokensImageSource.instance),
// MTG_ONL("mtg.onl", MtgOnlTokensImageSource.instance),
ALTERNATIVE("alternative.mtg.onl", AltMtgOnlTokensImageSource.instance),
GRAB_BAG("GrabBag", GrabbagImageSource.instance),
MAGIDEX("magidex.com", MagidexImageSource.instance),
SCRYFALL("scryfall.com", ScryfallImageSource.instance),
MAGICCARDS("magiccards.info", MagicCardsImageSource.instance);
SCRYFALL("scryfall.com", ScryfallImageSource.instance);
// MAGICCARDS("magiccards.info", MagicCardsImageSource.instance)
private final String text;
private final CardImageSource source;
@ -276,6 +276,8 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
}
}
break;
case ALL_TOKENS:
break;
default:
int nonSetEntries = 0;
if (cardImageSource.getSupportedSets() != null) {
@ -290,8 +292,9 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
int numberTokenImagesAvailable = 0;
int numberCardImagesAvailable = 0;
for (CardDownloadData data : allCardsMissingImage) {
if (data.isToken() && cardImageSource.isTokenSource()) {
if (cardImageSource.isImageProvided(data.getSet(), data.getName())) {
if (data.isToken()) {
if (cardImageSource.isTokenSource()
&& cardImageSource.isImageProvided(data.getSet(), data.getName())) {
numberTokenImagesAvailable++;
cardsToDownload.add(data);
}

View file

@ -1,5 +1,5 @@
#Generated by Maven
#Sun Sep 03 07:46:59 CEST 2017
#Fri Sep 15 22:14:29 CEST 2017
version=1.4.26
groupId=org.mage
artifactId=mage-game-pennydreadfulcommanderfreeforall