Merge pull request #934 from ImperatorPrime/master

Fixed some gatherer image loading.
This commit is contained in:
LevelX2 2015-04-26 17:35:50 +02:00
commit 9fb75d3877
6 changed files with 51 additions and 39 deletions

View file

@ -69,11 +69,11 @@ public class WizardCardsImageSource implements CardImageSource {
setsAliases.put("BRB", "Battle Royale Box Set"); setsAliases.put("BRB", "Battle Royale Box Set");
setsAliases.put("BTD", "Beatdown Box Set"); setsAliases.put("BTD", "Beatdown Box Set");
setsAliases.put("C13", "Commander 2013 Edition"); setsAliases.put("C13", "Commander 2013 Edition");
setsAliases.put("C14", "Commander 2014 Edition"); setsAliases.put("C14", "Commander 2014");
setsAliases.put("CHK", "Champions of Kamigawa"); setsAliases.put("CHK", "Champions of Kamigawa");
setsAliases.put("CHR", "Chronicles"); setsAliases.put("CHR", "Chronicles");
setsAliases.put("CMD", "Magic: The Gathering-Commander"); setsAliases.put("CMD", "Magic: The Gathering-Commander");
setsAliases.put("CNS", "Magic: The Gathering-Conspiracy"); setsAliases.put("CNS", "Magic: The GatheringConspiracy");
setsAliases.put("CON", "Conflux"); setsAliases.put("CON", "Conflux");
setsAliases.put("CSP", "Coldsnap"); setsAliases.put("CSP", "Coldsnap");
setsAliases.put("DD2", "Duel Decks: Jace vs. Chandra"); setsAliases.put("DD2", "Duel Decks: Jace vs. Chandra");
@ -179,7 +179,7 @@ public class WizardCardsImageSource implements CardImageSource {
setsAliases.put("TMP", "Tempest"); setsAliases.put("TMP", "Tempest");
setsAliases.put("TOR", "Torment"); setsAliases.put("TOR", "Torment");
setsAliases.put("TPR", "Tempest Remastered"); setsAliases.put("TPR", "Tempest Remastered");
setsAliases.put("TSB", "Time Spiral 'Timeshifted'"); setsAliases.put("TSB", "Time Spiral \"Timeshifted\"");
setsAliases.put("TSP", "Time Spiral"); setsAliases.put("TSP", "Time Spiral");
setsAliases.put("UDS", "Urza's Destiny"); setsAliases.put("UDS", "Urza's Destiny");
setsAliases.put("UGL", "Unglued"); setsAliases.put("UGL", "Unglued");
@ -254,6 +254,7 @@ public class WizardCardsImageSource implements CardImageSource {
String urlLandDocument = "http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=" + multiverseId; String urlLandDocument = "http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=" + multiverseId;
Document landDoc = Jsoup.connect(urlLandDocument).get(); Document landDoc = Jsoup.connect(urlLandDocument).get();
Elements variations = landDoc.select("a.variationlink"); Elements variations = landDoc.select("a.variationlink");
if(!variations.isEmpty()) {
int landNumber = 1; int landNumber = 1;
for (Element variation : variations) { for (Element variation : variations) {
Integer landMultiverseId = Integer.parseInt(variation.attr("onclick").replaceAll("[^\\d]", "")); Integer landMultiverseId = Integer.parseInt(variation.attr("onclick").replaceAll("[^\\d]", ""));
@ -264,6 +265,9 @@ public class WizardCardsImageSource implements CardImageSource {
} else { } else {
setLinks.put(cardName.toLowerCase(), cardsImages.get(i).attr("src").substring(5)); setLinks.put(cardName.toLowerCase(), cardsImages.get(i).attr("src").substring(5));
} }
} else {
setLinks.put(cardName.toLowerCase(), cardsImages.get(i).attr("src").substring(5));
}
} }
} }
page++; page++;
@ -276,6 +280,14 @@ public class WizardCardsImageSource implements CardImageSource {
} }
private String normalizeName(String name) { private String normalizeName(String name) {
//Split card
if(name.contains("//")) {
name = name.substring(0, name.indexOf("(") - 1);
}
//Special timeshifted name
if(name.startsWith("XX")) {
name = name.substring(name.indexOf("(") + 1, name.length() - 1);
}
return name.replace("\u2014", "-").replace("\u2019", "'") return name.replace("\u2014", "-").replace("\u2019", "'")
.replace("\u00C6", "AE").replace("\u00E6", "ae") .replace("\u00C6", "AE").replace("\u00E6", "ae")
.replace("\u00C3\u2020", "AE") .replace("\u00C3\u2020", "AE")

View file

@ -35,19 +35,19 @@ import java.util.UUID;
*/ */
public class Island1 extends mage.cards.basiclands.Island { public class Island extends mage.cards.basiclands.Island {
public Island1(UUID ownerId) { public Island(UUID ownerId) {
super(ownerId, 79); super(ownerId, 79);
this.expansionSetCode = "DDH"; this.expansionSetCode = "DDH";
} }
public Island1(final Island1 card) { public Island(final Island card) {
super(card); super(card);
} }
@Override @Override
public Island1 copy() { public Island copy() {
return new Island1(this); return new Island(this);
} }
} }

View file

@ -35,19 +35,19 @@ import java.util.UUID;
*/ */
public class Plains1 extends mage.cards.basiclands.Plains { public class Plains extends mage.cards.basiclands.Plains {
public Plains1(UUID ownerId) { public Plains(UUID ownerId) {
super(ownerId, 40); super(ownerId, 40);
this.expansionSetCode = "DDH"; this.expansionSetCode = "DDH";
} }
public Plains1(final Plains1 card) { public Plains(final Plains card) {
super(card); super(card);
} }
@Override @Override
public Plains1 copy() { public Plains copy() {
return new Plains1(this); return new Plains(this);
} }
} }

View file

@ -33,19 +33,19 @@ import java.util.UUID;
* *
* @author LevelX2 * @author LevelX2
*/ */
public class Island1 extends mage.cards.basiclands.Island { public class Island extends mage.cards.basiclands.Island {
public Island1(UUID ownerId) { public Island(UUID ownerId) {
super(ownerId, 68); super(ownerId, 68);
this.expansionSetCode = "DDE"; this.expansionSetCode = "DDE";
} }
public Island1(final Island1 card) { public Island(final Island card) {
super(card); super(card);
} }
@Override @Override
public Island1 copy() { public Island copy() {
return new Island1(this); return new Island(this);
} }
} }

View file

@ -33,19 +33,19 @@ import java.util.UUID;
* *
* @author LevelX2 * @author LevelX2
*/ */
public class Mountain1 extends mage.cards.basiclands.Mountain { public class Mountain extends mage.cards.basiclands.Mountain {
public Mountain1(UUID ownerId) { public Mountain(UUID ownerId) {
super(ownerId, 69); super(ownerId, 69);
this.expansionSetCode = "DDE"; this.expansionSetCode = "DDE";
} }
public Mountain1(final Mountain1 card) { public Mountain(final Mountain card) {
super(card); super(card);
} }
@Override @Override
public Mountain1 copy() { public Mountain copy() {
return new Mountain1(this); return new Mountain(this);
} }
} }

View file

@ -33,19 +33,19 @@ import java.util.UUID;
* *
* @author LevelX2 * @author LevelX2
*/ */
public class Plains1 extends mage.cards.basiclands.Plains { public class Plains extends mage.cards.basiclands.Plains {
public Plains1(UUID ownerId) { public Plains(UUID ownerId) {
super(ownerId, 67); super(ownerId, 67);
this.expansionSetCode = "DDE"; this.expansionSetCode = "DDE";
} }
public Plains1(final Plains1 card) { public Plains(final Plains card) {
super(card); super(card);
} }
@Override @Override
public Plains1 copy() { public Plains copy() {
return new Plains1(this); return new Plains(this);
} }
} }