mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Some fixes to symbol download for sets.
This commit is contained in:
parent
bb2044e70d
commit
8765f6ec45
2 changed files with 106 additions and 75 deletions
|
@ -153,6 +153,10 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
os.close();
|
os.close();
|
||||||
|
if (!dst.isValid()) {
|
||||||
|
dst.delete();
|
||||||
|
logger.warn("Resource not found " + job.getName() + " from " + job.getSource().toString());
|
||||||
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn("While closing", ex);
|
logger.warn("While closing", ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,12 @@ package org.mage.plugins.card.dl.sources;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import mage.cards.ExpansionSet;
|
||||||
|
import mage.cards.Sets;
|
||||||
import org.mage.plugins.card.dl.DownloadJob;
|
import org.mage.plugins.card.dl.DownloadJob;
|
||||||
import static org.mage.plugins.card.dl.DownloadJob.fromURL;
|
import static org.mage.plugins.card.dl.DownloadJob.fromURL;
|
||||||
import static org.mage.plugins.card.dl.DownloadJob.toFile;
|
import static org.mage.plugins.card.dl.DownloadJob.toFile;
|
||||||
|
@ -21,7 +25,7 @@ public class GathererSets implements Iterable<DownloadJob> {
|
||||||
"MIR", "VIS", "WTH",
|
"MIR", "VIS", "WTH",
|
||||||
"TMP", "STH", "EXO",
|
"TMP", "STH", "EXO",
|
||||||
"USG", "ULG", "UDS",
|
"USG", "ULG", "UDS",
|
||||||
"MMQ", "NMS", "PCY",
|
"MMQ", "NEM", "PCY",
|
||||||
"INV", "PLS", "APC",
|
"INV", "PLS", "APC",
|
||||||
"ODY", "TOR", "JUD",
|
"ODY", "TOR", "JUD",
|
||||||
"ONS", "LGN", "SCG",
|
"ONS", "LGN", "SCG",
|
||||||
|
@ -33,15 +37,13 @@ public class GathererSets implements Iterable<DownloadJob> {
|
||||||
"SHM", "EVE",
|
"SHM", "EVE",
|
||||||
"MED", "ME2", "ME3", "ME4",
|
"MED", "ME2", "ME3", "ME4",
|
||||||
"POR", "PO2", "PTK",
|
"POR", "PO2", "PTK",
|
||||||
"ARC",
|
"ARC", "DD3EVG",
|
||||||
"W16"};
|
"W16"};
|
||||||
|
|
||||||
private static final String[] withMythics = {"M10", "M11", "M12", "M13", "M14", "M15", "ORI",
|
private static final String[] withMythics = {"M10", "M11", "M12", "M13", "M14", "M15", "ORI",
|
||||||
"ANB",
|
"ANB",
|
||||||
"DDF", "DDG", "DDH", "DDI", "DDJ", "DDK", "DDL", "DDM", "DDN",
|
"DDF", "DDG", "DDH", "DDI", "DDJ", "DDK", "DDL", "DDM", "DDN",
|
||||||
"DD3", "DD3B", "DDO", "DDP", "DDQ", "DDR", "DDS",
|
"DD3DVD", "DD3GLV", "DD3JVC", "DDO", "DDP", "DDQ", "DDR", "DDS",
|
||||||
"FVD", "FVE", "FVL", "FVR",
|
|
||||||
"V12", "V13", "V14", "V15", "V16",
|
|
||||||
"ALA", "CON", "ARB",
|
"ALA", "CON", "ARB",
|
||||||
"ZEN", "WWK", "ROE",
|
"ZEN", "WWK", "ROE",
|
||||||
"SOM", "MBS", "NPH",
|
"SOM", "MBS", "NPH",
|
||||||
|
@ -54,50 +56,59 @@ public class GathererSets implements Iterable<DownloadJob> {
|
||||||
"CNS", "CN2",
|
"CNS", "CN2",
|
||||||
"VMA", "TPR",
|
"VMA", "TPR",
|
||||||
"KTK", "FRF", "DTK",
|
"KTK", "FRF", "DTK",
|
||||||
"BFZ", "EXP", "OGW",
|
"BFZ", "OGW",
|
||||||
"SOI", "EMN",
|
"SOI", "EMN",
|
||||||
"KLD", "MPS", "AER",
|
"KLD", "MPS", "AER",
|
||||||
"AKH", "HOU"
|
"AKH", "HOU"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final String[] onlyMythics = {
|
||||||
|
"DRB", "V09", "V12", "V12", "V13", "V14", "V15", "V16", "EXP"
|
||||||
|
};
|
||||||
|
|
||||||
private static final HashMap<String, String> symbolsReplacements = new HashMap<>();
|
private static final HashMap<String, String> symbolsReplacements = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
symbolsReplacements.put("2ED", "2U");
|
||||||
|
symbolsReplacements.put("3ED", "3E");
|
||||||
|
symbolsReplacements.put("4ED", "4E");
|
||||||
|
symbolsReplacements.put("5ED", "5E");
|
||||||
|
symbolsReplacements.put("6ED", "6E");
|
||||||
|
symbolsReplacements.put("7ED", "7E");
|
||||||
|
symbolsReplacements.put("ALL", "AL");
|
||||||
|
symbolsReplacements.put("APC", "AP");
|
||||||
symbolsReplacements.put("ARN", "AN");
|
symbolsReplacements.put("ARN", "AN");
|
||||||
symbolsReplacements.put("ATQ", "AQ");
|
symbolsReplacements.put("ATQ", "AQ");
|
||||||
symbolsReplacements.put("LEG", "LE");
|
symbolsReplacements.put("CMA", "CM1");
|
||||||
|
symbolsReplacements.put("DD3DVD", "DD3_DVD");
|
||||||
|
symbolsReplacements.put("DD3EVG", "DD3_EVG");
|
||||||
|
symbolsReplacements.put("DD3GLV", "DD3_GLV");
|
||||||
|
symbolsReplacements.put("DD3JVC", "DD3_JVC");
|
||||||
symbolsReplacements.put("DRK", "DK");
|
symbolsReplacements.put("DRK", "DK");
|
||||||
|
symbolsReplacements.put("EXO", "EX");
|
||||||
symbolsReplacements.put("FEM", "FE");
|
symbolsReplacements.put("FEM", "FE");
|
||||||
symbolsReplacements.put("HML", "HM");
|
symbolsReplacements.put("HML", "HM");
|
||||||
symbolsReplacements.put("ICE", "IA");
|
symbolsReplacements.put("ICE", "IA");
|
||||||
symbolsReplacements.put("ALL", "AL");
|
|
||||||
symbolsReplacements.put("APC", "AP");
|
|
||||||
symbolsReplacements.put("TMP", "TE");
|
|
||||||
symbolsReplacements.put("INV", "IN");
|
symbolsReplacements.put("INV", "IN");
|
||||||
|
symbolsReplacements.put("LEA", "1E");
|
||||||
|
symbolsReplacements.put("LEB", "2E");
|
||||||
|
symbolsReplacements.put("LEG", "LE");
|
||||||
|
symbolsReplacements.put("MIR", "MI");
|
||||||
|
symbolsReplacements.put("MMQ", "MM");
|
||||||
|
symbolsReplacements.put("NEM", "NE");
|
||||||
|
symbolsReplacements.put("ODY", "OD");
|
||||||
|
symbolsReplacements.put("PCY", "PR");
|
||||||
symbolsReplacements.put("PLS", "PS");
|
symbolsReplacements.put("PLS", "PS");
|
||||||
symbolsReplacements.put("WTH", "WL");
|
symbolsReplacements.put("POR", "PO");
|
||||||
|
symbolsReplacements.put("PO2", "P2");
|
||||||
|
symbolsReplacements.put("PTK", "PK");
|
||||||
|
symbolsReplacements.put("STH", "ST");
|
||||||
|
symbolsReplacements.put("TMP", "TE");
|
||||||
|
symbolsReplacements.put("UDS", "CG");
|
||||||
symbolsReplacements.put("ULG", "GU");
|
symbolsReplacements.put("ULG", "GU");
|
||||||
symbolsReplacements.put("USG", "UZ");
|
symbolsReplacements.put("USG", "UZ");
|
||||||
symbolsReplacements.put("UDS", "CG");
|
|
||||||
symbolsReplacements.put("ODY", "OD");
|
|
||||||
symbolsReplacements.put("MMQ", "MM");
|
|
||||||
symbolsReplacements.put("NMS", "NE");
|
|
||||||
symbolsReplacements.put("PCY", "PR");
|
|
||||||
symbolsReplacements.put("STH", "ST");
|
|
||||||
symbolsReplacements.put("EXO", "EX");
|
|
||||||
symbolsReplacements.put("VIS", "VI");
|
symbolsReplacements.put("VIS", "VI");
|
||||||
symbolsReplacements.put("MIR", "MI");
|
symbolsReplacements.put("WTH", "WL");
|
||||||
symbolsReplacements.put("7ED", "7E");
|
|
||||||
symbolsReplacements.put("6ED", "6E");
|
|
||||||
symbolsReplacements.put("5ED", "5E");
|
|
||||||
symbolsReplacements.put("4ED", "4E");
|
|
||||||
symbolsReplacements.put("3ED", "3E");
|
|
||||||
symbolsReplacements.put("2ED", "2U");
|
|
||||||
symbolsReplacements.put("LEB", "2E");
|
|
||||||
symbolsReplacements.put("LEA", "1E");
|
|
||||||
symbolsReplacements.put("DD3A", "DD3");
|
|
||||||
symbolsReplacements.put("DD3B", "DD3");
|
|
||||||
symbolsReplacements.put("DD3C", "DD3");
|
|
||||||
symbolsReplacements.put("DD3D", "DD3");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GathererSets(String path) {
|
public GathererSets(String path) {
|
||||||
|
@ -110,18 +121,34 @@ public class GathererSets implements Iterable<DownloadJob> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<DownloadJob> iterator() {
|
public Iterator<DownloadJob> iterator() {
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(new Date());
|
||||||
|
c.add(Calendar.DATE, -14);
|
||||||
|
Date compareDate = c.getTime();
|
||||||
ArrayList<DownloadJob> jobs = new ArrayList<>();
|
ArrayList<DownloadJob> jobs = new ArrayList<>();
|
||||||
for (String symbol : symbols) {
|
for (String symbol : symbols) {
|
||||||
|
ExpansionSet exp = Sets.findSet(symbol);
|
||||||
|
if (exp != null && exp.getReleaseDate().before(compareDate)) {
|
||||||
jobs.add(generateDownloadJob(symbol, "C"));
|
jobs.add(generateDownloadJob(symbol, "C"));
|
||||||
jobs.add(generateDownloadJob(symbol, "U"));
|
jobs.add(generateDownloadJob(symbol, "U"));
|
||||||
jobs.add(generateDownloadJob(symbol, "R"));
|
jobs.add(generateDownloadJob(symbol, "R"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (String symbol : withMythics) {
|
for (String symbol : withMythics) {
|
||||||
|
ExpansionSet exp = Sets.findSet(symbol);
|
||||||
|
if (exp != null && exp.getReleaseDate().before(compareDate)) {
|
||||||
jobs.add(generateDownloadJob(symbol, "C"));
|
jobs.add(generateDownloadJob(symbol, "C"));
|
||||||
jobs.add(generateDownloadJob(symbol, "U"));
|
jobs.add(generateDownloadJob(symbol, "U"));
|
||||||
jobs.add(generateDownloadJob(symbol, "R"));
|
jobs.add(generateDownloadJob(symbol, "R"));
|
||||||
jobs.add(generateDownloadJob(symbol, "M"));
|
jobs.add(generateDownloadJob(symbol, "M"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
for (String symbol : onlyMythics) {
|
||||||
|
ExpansionSet exp = Sets.findSet(symbol);
|
||||||
|
if (exp != null && exp.getReleaseDate().before(compareDate)) {
|
||||||
|
jobs.add(generateDownloadJob(symbol, "M"));
|
||||||
|
}
|
||||||
|
}
|
||||||
return jobs.iterator();
|
return jobs.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue