mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
merge
This commit is contained in:
commit
1f7a32ef90
3 changed files with 44 additions and 1 deletions
Binary file not shown.
|
@ -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() {
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue