now we downloading all rarities icon's variants for sets

This commit is contained in:
Loki 2011-01-14 11:13:13 +02:00
parent 06259f856c
commit 594aca8183

View file

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