mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
Added mtgathering.ru download source.
This commit is contained in:
parent
7efc3b953b
commit
e649e8ec62
3 changed files with 83 additions and 2 deletions
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package org.mage.plugins.card.dl.sources;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.mage.plugins.card.utils.CardImageUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author North
|
||||||
|
*/
|
||||||
|
public class MtgatheringRuImageSource implements CardImageSource {
|
||||||
|
|
||||||
|
private static CardImageSource hqInstance;
|
||||||
|
private static CardImageSource mqInstance;
|
||||||
|
private static CardImageSource lqInstance;
|
||||||
|
private static final Map setsAliases;
|
||||||
|
|
||||||
|
static {
|
||||||
|
setsAliases = new HashMap();
|
||||||
|
setsAliases.put("MBS", "mirrodinbesieged");
|
||||||
|
setsAliases.put("M11", "magic2011");
|
||||||
|
}
|
||||||
|
private String quality;
|
||||||
|
|
||||||
|
public static CardImageSource getHqInstance() {
|
||||||
|
if (hqInstance == null) {
|
||||||
|
hqInstance = new MtgatheringRuImageSource("hq");
|
||||||
|
}
|
||||||
|
return hqInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CardImageSource getMqInstance() {
|
||||||
|
if (mqInstance == null) {
|
||||||
|
mqInstance = new MtgatheringRuImageSource("md");
|
||||||
|
}
|
||||||
|
return mqInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CardImageSource getLqInstance() {
|
||||||
|
if (lqInstance == null) {
|
||||||
|
lqInstance = new MtgatheringRuImageSource("lq");
|
||||||
|
}
|
||||||
|
return lqInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MtgatheringRuImageSource(String quality) {
|
||||||
|
this.quality = quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String generateURL(Integer collectorId, String cardSet) throws Exception {
|
||||||
|
if (collectorId == null || cardSet == null) {
|
||||||
|
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet);
|
||||||
|
}
|
||||||
|
if (setsAliases.get(cardSet) == null) {
|
||||||
|
String set = CardImageUtils.updateSet(cardSet, true);
|
||||||
|
String url = "http://magiccards.info/scans/en/";
|
||||||
|
url += set.toLowerCase() + "/" + collectorId + ".jpg";
|
||||||
|
|
||||||
|
return url;
|
||||||
|
} else {
|
||||||
|
String set = CardImageUtils.updateSet(cardSet, true);
|
||||||
|
String url = "http://mtgathering.ru/scans/en/";
|
||||||
|
url += set.toLowerCase() + "/" + quality + "/" + collectorId + ".jpg";
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -50,6 +50,7 @@ import org.mage.plugins.card.CardUrl;
|
||||||
import org.mage.plugins.card.constants.Constants;
|
import org.mage.plugins.card.constants.Constants;
|
||||||
import org.mage.plugins.card.dl.sources.CardImageSource;
|
import org.mage.plugins.card.dl.sources.CardImageSource;
|
||||||
import org.mage.plugins.card.dl.sources.MagicCardsImageSource;
|
import org.mage.plugins.card.dl.sources.MagicCardsImageSource;
|
||||||
|
import org.mage.plugins.card.dl.sources.MtgatheringRuImageSource;
|
||||||
import org.mage.plugins.card.dl.sources.WizardCardsImageSource;
|
import org.mage.plugins.card.dl.sources.WizardCardsImageSource;
|
||||||
import org.mage.plugins.card.properties.SettingsManager;
|
import org.mage.plugins.card.properties.SettingsManager;
|
||||||
import org.mage.plugins.card.utils.CardImageUtils;
|
import org.mage.plugins.card.utils.CardImageUtils;
|
||||||
|
|
@ -156,7 +157,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
|
|
||||||
p0.add(jLabel1);
|
p0.add(jLabel1);
|
||||||
p0.add(Box.createVerticalStrut(5));
|
p0.add(Box.createVerticalStrut(5));
|
||||||
ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "magiccards.info", "wizards.com" });
|
ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "magiccards.info", "wizards.com", "mtgathering.ru HQ", "mtgathering.ru MQ", "mtgathering.ru LQ"});
|
||||||
jComboBox1 = new JComboBox();
|
jComboBox1 = new JComboBox();
|
||||||
|
|
||||||
cardImageSource = MagicCardsImageSource.getInstance();
|
cardImageSource = MagicCardsImageSource.getInstance();
|
||||||
|
|
@ -174,6 +175,15 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
case 1:
|
case 1:
|
||||||
cardImageSource = WizardCardsImageSource.getInstance();
|
cardImageSource = WizardCardsImageSource.getInstance();
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
cardImageSource = MtgatheringRuImageSource.getHqInstance();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
cardImageSource = MtgatheringRuImageSource.getMqInstance();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
cardImageSource = MtgatheringRuImageSource.getLqInstance();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package org.mage.plugins.card.utils;
|
package org.mage.plugins.card.utils;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
public interface ImageManager {
|
public interface ImageManager {
|
||||||
public Image getSicknessImage();
|
public Image getSicknessImage();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue