spjspj - Add in promos from scg to grabbag. Fixed some badly numbered lands (probably more are bad).

This commit is contained in:
spjspj 2016-10-27 16:02:00 +11:00
parent c663cd24e9
commit 1dae8ca6b2
2 changed files with 824 additions and 336 deletions

View file

@ -363,6 +363,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
for (CardDownloadData card : allCardsUrls) { for (CardDownloadData card : allCardsUrls) {
file = new TFile(CardImageUtils.generateImagePath(card)); file = new TFile(CardImageUtils.generateImagePath(card));
if (!file.exists()) { if (!file.exists()) {
logger.debug("Missing: " + file.getAbsolutePath());
cardsToDownload.add(card); cardsToDownload.add(card);
} }
} }
@ -646,12 +647,21 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
BufferedOutputStream out; BufferedOutputStream out;
// Logger.getLogger(this.getClass()).info(url.toString()); // Logger.getLogger(this.getClass()).info(url.toString());
URLConnection httpConn = url.openConnection(p); boolean useTempFile = false;
setUpConnection(httpConn); int responseCode = 0;
URLConnection httpConn = null;
if (temporaryFile != null && temporaryFile.length() > 100) {
useTempFile = true;
} else {
httpConn = url.openConnection(p);
setUpConnection(httpConn);
httpConn.connect(); httpConn.connect();
int responseCode = ((HttpURLConnection) httpConn).getResponseCode(); responseCode = ((HttpURLConnection) httpConn).getResponseCode();
if (responseCode == 200) { }
if (responseCode == 200 || useTempFile) {
if (!useTempFile) {
try (BufferedInputStream in = new BufferedInputStream(((HttpURLConnection) httpConn).getInputStream())) { try (BufferedInputStream in = new BufferedInputStream(((HttpURLConnection) httpConn).getInputStream())) {
//try (BufferedInputStream in = new BufferedInputStream(url.openConnection(p).getInputStream())) { //try (BufferedInputStream in = new BufferedInputStream(url.openConnection(p).getInputStream())) {
out = new BufferedOutputStream(new TFileOutputStream(temporaryFile)); out = new BufferedOutputStream(new TFileOutputStream(temporaryFile));
@ -672,6 +682,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
} }
out.flush(); out.flush();
out.close(); out.close();
}
if (card != null && card.isTwoFacedCard()) { if (card != null && card.isTwoFacedCard()) {
BufferedImage image = ImageIO.read(temporaryFile); BufferedImage image = ImageIO.read(temporaryFile);
@ -690,7 +701,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
outputFile.getParentFile().mkdirs(); outputFile.getParentFile().mkdirs();
new TFile(temporaryFile).cp_rp(outputFile); new TFile(temporaryFile).cp_rp(outputFile);
} }
temporaryFile.delete(); //temporaryFile.delete();
} else { } else {
outputFile.getParentFile().mkdirs(); outputFile.getParentFile().mkdirs();
new TFile(temporaryFile).cp_rp(outputFile); new TFile(temporaryFile).cp_rp(outputFile);
@ -712,7 +723,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
logger.error(e, e); logger.error(e, e);
} finally { } finally {
if (temporaryFile != null) { if (temporaryFile != null) {
temporaryFile.delete(); //temporaryFile.delete();
} }
} }
synchronized (sync) { synchronized (sync) {