diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java index cb1fe115e8..63f5fdba85 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java @@ -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 { 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 iterator() { - return new AbstractIterator() { - private int idx = 0; + ArrayList jobs = new ArrayList(); + 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"; - } - 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)); - } - }; + 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=" + set + "&size=small&rarity=" + rarity; + return new DownloadJob(set + "-" + rarity, fromURL(url), toFile(dst)); } }