mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Fixed that not BFZ images were downloaded from mysticspoliers source. Fixed that Zendikar Expeditions images were not downloaded from mysticspoliers source.
This commit is contained in:
parent
75bb39cae8
commit
ed15f0b86b
3 changed files with 41 additions and 20 deletions
|
@ -36,7 +36,10 @@ import java.net.Proxy;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.remote.Connection;
|
import mage.remote.Connection;
|
||||||
|
@ -56,6 +59,7 @@ public class MythicspoilerComSource implements CardImageSource {
|
||||||
private static CardImageSource instance;
|
private static CardImageSource instance;
|
||||||
private static Map<String, String> setsAliases;
|
private static Map<String, String> setsAliases;
|
||||||
private static Map<String, String> cardNameAliases;
|
private static Map<String, String> cardNameAliases;
|
||||||
|
private static Map<String, Set<String>> cardNameAliasesStart;
|
||||||
private final Map<String, Map<String, String>> sets;
|
private final Map<String, Map<String, String>> sets;
|
||||||
|
|
||||||
public static CardImageSource getInstance() {
|
public static CardImageSource getInstance() {
|
||||||
|
@ -71,8 +75,9 @@ public class MythicspoilerComSource implements CardImageSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MythicspoilerComSource() {
|
public MythicspoilerComSource() {
|
||||||
sets = new HashMap<>();
|
sets = new LinkedHashMap<>();
|
||||||
setsAliases = new HashMap<>();
|
setsAliases = new HashMap<>();
|
||||||
|
setsAliases.put("exp", "bfz");
|
||||||
cardNameAliases = new HashMap<>();
|
cardNameAliases = new HashMap<>();
|
||||||
// set+wrong name from web side => correct card name
|
// set+wrong name from web side => correct card name
|
||||||
cardNameAliases.put("MM2-otherwordlyjourney", "otherworldlyjourney");
|
cardNameAliases.put("MM2-otherwordlyjourney", "otherworldlyjourney");
|
||||||
|
@ -81,12 +86,21 @@ public class MythicspoilerComSource implements CardImageSource {
|
||||||
cardNameAliases.put("THS-soldierofpantheon", "soldierofthepantheon");
|
cardNameAliases.put("THS-soldierofpantheon", "soldierofthepantheon");
|
||||||
cardNameAliases.put("THS-vulpinegolaith", "vulpinegoliath");
|
cardNameAliases.put("THS-vulpinegolaith", "vulpinegoliath");
|
||||||
cardNameAliases.put("ORI-kothopedhoarderofsouls", "kothophedsoulhoarder");
|
cardNameAliases.put("ORI-kothopedhoarderofsouls", "kothophedsoulhoarder");
|
||||||
|
cardNameAliases.put("BFZ-unisonstrike", "tandemtactics");
|
||||||
|
cardNameAliases.put("BFZ-eldrazidevastator", "eldrazidevastator");
|
||||||
|
cardNameAliases.put("BFZ-kozliekschanneler", "kozilekschanneler");
|
||||||
|
|
||||||
|
cardNameAliasesStart = new HashMap<>();
|
||||||
|
HashSet<String> names = new HashSet<>();
|
||||||
|
names.add("eldrazidevastator.jpg");
|
||||||
|
cardNameAliasesStart.put("BFZ", names);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> getSetLinks(String cardSet) {
|
private Map<String, String> getSetLinks(String cardSet) {
|
||||||
Map<String, String> setLinks = new HashMap<>();
|
Map<String, String> setLinks = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
String setNames = setsAliases.get(cardSet.toLowerCase());
|
String setNames = setsAliases.get(cardSet.toLowerCase());
|
||||||
|
Set<String> aliasesStart = cardNameAliasesStart.get(cardSet);
|
||||||
if (setNames == null) {
|
if (setNames == null) {
|
||||||
setNames = cardSet.toLowerCase();
|
setNames = cardSet.toLowerCase();
|
||||||
}
|
}
|
||||||
|
@ -119,33 +133,40 @@ public class MythicspoilerComSource implements CardImageSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
Elements cardsImages = doc.select("img[src^=cards/]"); // starts with cards/
|
Elements cardsImages = doc.select("img[src^=cards/]"); // starts with cards/
|
||||||
|
for (String text : aliasesStart) {
|
||||||
|
cardsImages.addAll(doc.select("img[src^=" + text + "]"));
|
||||||
|
}
|
||||||
if (cardsImages.isEmpty()) {
|
if (cardsImages.isEmpty()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Element cardsImage : cardsImages) {
|
for (Element cardsImage : cardsImages) {
|
||||||
String cardLink = cardsImage.attr("src");
|
String cardLink = cardsImage.attr("src");
|
||||||
|
String cardName = null;
|
||||||
if (cardLink.startsWith("cards/") && cardLink.endsWith(".jpg")) {
|
if (cardLink.startsWith("cards/") && cardLink.endsWith(".jpg")) {
|
||||||
String cardName = cardLink.substring(6, cardLink.length() - 4);
|
cardName = cardLink.substring(6, cardLink.length() - 4);
|
||||||
if (cardName != null && !cardName.isEmpty()) {
|
} else if (aliasesStart.contains(cardLink)) {
|
||||||
if (cardNameAliases.containsKey(cardSet + "-" + cardName)) {
|
cardName = cardLink.substring(0, cardLink.length() - 4);;
|
||||||
cardName = cardNameAliases.get(cardSet + "-" + cardName);
|
}
|
||||||
}
|
if (cardName != null && !cardName.isEmpty()) {
|
||||||
if (cardName.endsWith("1") || cardName.endsWith("2") || cardName.endsWith("3") || cardName.endsWith("4") || cardName.endsWith("5")) {
|
if (cardNameAliases.containsKey(cardSet + "-" + cardName)) {
|
||||||
if (!cardName.startsWith("forest")
|
cardName = cardNameAliases.get(cardSet + "-" + cardName);
|
||||||
&& !cardName.startsWith("swamp")
|
}
|
||||||
&& !cardName.startsWith("mountain")
|
if (cardName.endsWith("1") || cardName.endsWith("2") || cardName.endsWith("3") || cardName.endsWith("4") || cardName.endsWith("5")) {
|
||||||
&& !cardName.startsWith("island")
|
if (!cardName.startsWith("forest")
|
||||||
&& !cardName.startsWith("plains")) {
|
&& !cardName.startsWith("swamp")
|
||||||
cardName = cardName.substring(0, cardName.length() - 1);
|
&& !cardName.startsWith("mountain")
|
||||||
}
|
&& !cardName.startsWith("island")
|
||||||
}
|
&& !cardName.startsWith("plains")) {
|
||||||
setLinks.put(cardName, baseUrl + cardLink);
|
cardName = cardName.substring(0, cardName.length() - 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
setLinks.put(cardName, baseUrl + cardLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println("Exception when parsing the mythicspoiler page: " + ex.getMessage());
|
System.out.println("Exception when parsing the mythicspoiler page: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,6 @@ ddd=gvl
|
||||||
unh=uh
|
unh=uh
|
||||||
dde=pvc
|
dde=pvc
|
||||||
# Remove setname as soon as the images can be downloaded
|
# Remove setname as soon as the images can be downloaded
|
||||||
ignore.urls=TOK,EXP,OGW
|
ignore.urls=TOK, OGW
|
||||||
# sets ordered by release time (newest goes first)
|
# sets ordered by release time (newest goes first)
|
||||||
token.lookup.order=OGW,EXP,DDP,BFZ,FVD,FVE,FVL,FVR,V12,V13,V14,V15,TPR,MPRP,DD3,DDO,ORI,MM2,PTC,DTK,FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC
|
token.lookup.order=OGW,EXP,DDP,BFZ,FVD,FVE,FVL,FVR,V12,V13,V14,V15,TPR,MPRP,DD3,DDO,ORI,MM2,PTC,DTK,FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC
|
|
@ -52,7 +52,7 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
*/
|
*/
|
||||||
public class TitansPresence extends CardImpl {
|
public class TitansPresence extends CardImpl {
|
||||||
|
|
||||||
private static final FilterCreatureCard filter = new FilterCreatureCard("a colorless creature card from your hand to reveal");
|
private static final FilterCreatureCard filter = new FilterCreatureCard("a colorless creature card from your hand");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(new ColorlessPredicate());
|
filter.add(new ColorlessPredicate());
|
||||||
|
|
Loading…
Reference in a new issue