This commit is contained in:
maurer.it 2011-01-08 18:40:11 -05:00
commit 1f7a32ef90
3 changed files with 44 additions and 1 deletions

View file

@ -35,6 +35,7 @@ import org.mage.plugins.card.constants.Constants;
import org.mage.plugins.card.dl.DownloadGui; import org.mage.plugins.card.dl.DownloadGui;
import org.mage.plugins.card.dl.DownloadJob; import org.mage.plugins.card.dl.DownloadJob;
import org.mage.plugins.card.dl.Downloader; import org.mage.plugins.card.dl.Downloader;
import org.mage.plugins.card.dl.sources.GathererSets;
import org.mage.plugins.card.dl.sources.GathererSymbols; import org.mage.plugins.card.dl.sources.GathererSymbols;
import org.mage.plugins.card.images.DownloadPictures; import org.mage.plugins.card.images.DownloadPictures;
import org.mage.plugins.card.info.CardInfoPaneImpl; import org.mage.plugins.card.info.CardInfoPaneImpl;
@ -416,7 +417,13 @@ public class CardPluginImpl implements CardPlugin {
for(DownloadJob job:it) { for(DownloadJob job:it) {
g.getDownloader().add(job); g.getDownloader().add(job);
} }
it = new GathererSets();
for(DownloadJob job:it) {
g.getDownloader().add(job);
}
JDialog d = new JDialog((Frame) null, "Download pictures", false); JDialog d = new JDialog((Frame) null, "Download pictures", false);
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.addWindowListener(new WindowAdapter() { d.addWindowListener(new WindowAdapter() {

View file

@ -0,0 +1,36 @@
package org.mage.plugins.card.dl.sources;
import com.google.common.collect.AbstractIterator;
import org.mage.plugins.card.dl.DownloadJob;
import java.io.File;
import java.util.Iterator;
import static org.mage.plugins.card.dl.DownloadJob.fromURL;
import static org.mage.plugins.card.dl.DownloadJob.toFile;
public class GathererSets implements Iterable<DownloadJob> {
private static final File outDir = new File("plugins/images/sets");
private static final String[] symbols = { "M10", "M11", "ARB", "DIS", "GPT", "RAV", "ALA",
"ZEN", "WWK", "ROE", "SOM", "10E", "CFX" };
@Override
public Iterator<DownloadJob> iterator() {
return new AbstractIterator<DownloadJob>() {
private int idx = 0;
@Override
protected DownloadJob computeNext() {
if (idx == symbols.length) return endOfData();
String symbol = symbols[idx];
File dst = new File(outDir, symbol + ".jpg");
if (symbol.equals("CFX")) { // hack for special reserved filaname "CON" in Windows
symbol = "CON";
}
String url = "http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=" + symbol + "&size=small&rarity=R";
idx++;
return new DownloadJob(symbol, fromURL(url), toFile(dst));
}
};
}
}