mirror of
https://github.com/correl/mage.git
synced 2024-11-24 19:19:56 +00:00
Some updates to image download.
This commit is contained in:
parent
a280605591
commit
3fc3d96fe0
4 changed files with 29 additions and 6 deletions
|
@ -376,4 +376,10 @@ public enum MtgOnlTokensImageSource implements CardImageSource {
|
||||||
@Override
|
@Override
|
||||||
public void doPause(String httpImageUrl) {
|
public void doPause(String httpImageUrl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isImageProvided(String setCode, String cardName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,10 @@ import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mage.plugins.card.images.CardDownloadData;
|
import org.mage.plugins.card.images.CardDownloadData;
|
||||||
|
@ -53,6 +55,11 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
private HashMap<String, ArrayList<TokenData>> tokensData;
|
private HashMap<String, ArrayList<TokenData>> tokensData;
|
||||||
|
|
||||||
private final Object tokensDataSync = new Object();
|
private final Object tokensDataSync = new Object();
|
||||||
|
private final Set<String> supportedSets;
|
||||||
|
|
||||||
|
private TokensMtgImageSource() {
|
||||||
|
this.supportedSets = new LinkedHashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSourceName() {
|
public String getSourceName() {
|
||||||
|
@ -201,6 +208,7 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
List<TokenData> siteTokensData = parseTokensData(inputStream);
|
List<TokenData> siteTokensData = parseTokensData(inputStream);
|
||||||
for (TokenData siteData : siteTokensData) {
|
for (TokenData siteData : siteTokensData) {
|
||||||
String key = siteData.getExpansionSetCode() + "/" + siteData.getName();
|
String key = siteData.getExpansionSetCode() + "/" + siteData.getName();
|
||||||
|
supportedSets.add(siteData.getExpansionSetCode());
|
||||||
ArrayList<TokenData> list = tokensData.get(key);
|
ArrayList<TokenData> list = tokensData.get(key);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
|
@ -335,4 +343,10 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> getSupportedSets() {
|
||||||
|
ArrayList<String> supportedSetsCopy = new ArrayList<>();
|
||||||
|
supportedSetsCopy.addAll(supportedSets);
|
||||||
|
return supportedSetsCopy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,12 +81,12 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
WIZARDS("wizards.com", WizardCardsImageSource.instance),
|
WIZARDS("wizards.com", WizardCardsImageSource.instance),
|
||||||
MYTHICSPOILER("mythicspoiler.com", MythicspoilerComSource.instance),
|
MYTHICSPOILER("mythicspoiler.com", MythicspoilerComSource.instance),
|
||||||
TOKENS("tokens.mtg.onl", TokensMtgImageSource.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),
|
ALTERNATIVE("alternative.mtg.onl", AltMtgOnlTokensImageSource.instance),
|
||||||
GRAB_BAG("GrabBag", GrabbagImageSource.instance),
|
GRAB_BAG("GrabBag", GrabbagImageSource.instance),
|
||||||
MAGIDEX("magidex.com", MagidexImageSource.instance),
|
MAGIDEX("magidex.com", MagidexImageSource.instance),
|
||||||
SCRYFALL("scryfall.com", ScryfallImageSource.instance),
|
SCRYFALL("scryfall.com", ScryfallImageSource.instance);
|
||||||
MAGICCARDS("magiccards.info", MagicCardsImageSource.instance);
|
// MAGICCARDS("magiccards.info", MagicCardsImageSource.instance)
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
private final CardImageSource source;
|
private final CardImageSource source;
|
||||||
|
@ -276,6 +276,8 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ALL_TOKENS:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
int nonSetEntries = 0;
|
int nonSetEntries = 0;
|
||||||
if (cardImageSource.getSupportedSets() != null) {
|
if (cardImageSource.getSupportedSets() != null) {
|
||||||
|
@ -290,8 +292,9 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
int numberTokenImagesAvailable = 0;
|
int numberTokenImagesAvailable = 0;
|
||||||
int numberCardImagesAvailable = 0;
|
int numberCardImagesAvailable = 0;
|
||||||
for (CardDownloadData data : allCardsMissingImage) {
|
for (CardDownloadData data : allCardsMissingImage) {
|
||||||
if (data.isToken() && cardImageSource.isTokenSource()) {
|
if (data.isToken()) {
|
||||||
if (cardImageSource.isImageProvided(data.getSet(), data.getName())) {
|
if (cardImageSource.isTokenSource()
|
||||||
|
&& cardImageSource.isImageProvided(data.getSet(), data.getName())) {
|
||||||
numberTokenImagesAvailable++;
|
numberTokenImagesAvailable++;
|
||||||
cardsToDownload.add(data);
|
cardsToDownload.add(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#Generated by Maven
|
#Generated by Maven
|
||||||
#Sun Sep 03 07:46:59 CEST 2017
|
#Fri Sep 15 22:14:29 CEST 2017
|
||||||
version=1.4.26
|
version=1.4.26
|
||||||
groupId=org.mage
|
groupId=org.mage
|
||||||
artifactId=mage-game-pennydreadfulcommanderfreeforall
|
artifactId=mage-game-pennydreadfulcommanderfreeforall
|
||||||
|
|
Loading…
Reference in a new issue