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 java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
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> {
private static final File outDir = new File("plugins/images/sets");
private static final String[] symbols = { "M10", "M11", "ARB", "DIS", "GPT", "RAV", "ALA", "MRD",
"ZEN", "WWK", "ROE", "SOM", "10E", "CFX", "HOP", };
private static final String[] symbols = {"DIS", "GPT", "RAV", "MRD",
"10E", "HOP"};
private static final String[] withMythics = {"ALA", "CFX", "ARB", "ZEN", "WWK", "ROE", "SOM", "M10","M11"};
@Override
public Iterator<DownloadJob> iterator() {
return new AbstractIterator<DownloadJob>() {
private int idx = 0;
ArrayList<DownloadJob> jobs = new ArrayList<DownloadJob>();
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
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";
private DownloadJob generateDownloadJob(String set, String rarity) {
File dst = new File(outDir, set + "-" + rarity + ".jpg");
if (set.equals("CFX")) { // hack for special reserved filaname "CON" in Windows
set = "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));
}
};
String url = "http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=" + set + "&size=small&rarity=" + rarity;
return new DownloadJob(set + "-" + rarity, fromURL(url), toFile(dst));
}
}