mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
spjspj - Add 'grab-bag' of images that seem harder to get.
This commit is contained in:
parent
0042dc1ad9
commit
a0c09ecf6a
11 changed files with 1164 additions and 8 deletions
|
@ -173,4 +173,9 @@ public class AltMtgOnlTokensImageSource implements CardImageSource {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isTokenSource() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,4 +15,5 @@ public interface CardImageSource {
|
||||||
String getSourceName();
|
String getSourceName();
|
||||||
Float getAverageSize();
|
Float getAverageSize();
|
||||||
Integer getTotalImages();
|
Integer getTotalImages();
|
||||||
|
Boolean isTokenSource();
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -221,4 +221,9 @@ public class MagicCardsImageSource implements CardImageSource {
|
||||||
public Integer getTotalImages() {
|
public Integer getTotalImages() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isTokenSource() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,4 +110,9 @@ public class MtgImageSource implements CardImageSource {
|
||||||
public Integer getTotalImages() {
|
public Integer getTotalImages() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isTokenSource() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -373,4 +373,9 @@ public class MtgOnlTokensImageSource implements CardImageSource {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isTokenSource() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,4 +249,9 @@ public class MythicspoilerComSource implements CardImageSource {
|
||||||
public Integer getTotalImages() {
|
public Integer getTotalImages() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isTokenSource() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,4 +334,9 @@ public class TokensMtgImageSource implements CardImageSource {
|
||||||
public Integer getTotalImages() {
|
public Integer getTotalImages() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isTokenSource() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,4 +516,9 @@ public class WizardCardsImageSource implements CardImageSource {
|
||||||
public Integer getTotalImages() {
|
public Integer getTotalImages() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isTokenSource() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ import org.mage.plugins.card.dl.sources.CardImageSource;
|
||||||
import org.mage.plugins.card.dl.sources.MagicCardsImageSource;
|
import org.mage.plugins.card.dl.sources.MagicCardsImageSource;
|
||||||
import org.mage.plugins.card.dl.sources.MtgOnlTokensImageSource;
|
import org.mage.plugins.card.dl.sources.MtgOnlTokensImageSource;
|
||||||
import org.mage.plugins.card.dl.sources.AltMtgOnlTokensImageSource;
|
import org.mage.plugins.card.dl.sources.AltMtgOnlTokensImageSource;
|
||||||
|
import org.mage.plugins.card.dl.sources.GrabbagImageSource;
|
||||||
import org.mage.plugins.card.dl.sources.MythicspoilerComSource;
|
import org.mage.plugins.card.dl.sources.MythicspoilerComSource;
|
||||||
import org.mage.plugins.card.dl.sources.TokensMtgImageSource;
|
import org.mage.plugins.card.dl.sources.TokensMtgImageSource;
|
||||||
import org.mage.plugins.card.dl.sources.WizardCardsImageSource;
|
import org.mage.plugins.card.dl.sources.WizardCardsImageSource;
|
||||||
|
@ -148,7 +149,8 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
"mythicspoiler.com",
|
"mythicspoiler.com",
|
||||||
"tokens.mtg.onl", //"mtgimage.com (HQ)",
|
"tokens.mtg.onl", //"mtgimage.com (HQ)",
|
||||||
"mtg.onl",
|
"mtg.onl",
|
||||||
"alternative.mtg.onl"
|
"alternative.mtg.onl",
|
||||||
|
"GrabBag"
|
||||||
//"mtgathering.ru HQ",
|
//"mtgathering.ru HQ",
|
||||||
//"mtgathering.ru MQ",
|
//"mtgathering.ru MQ",
|
||||||
//"mtgathering.ru LQ",
|
//"mtgathering.ru LQ",
|
||||||
|
@ -182,6 +184,9 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
case 5:
|
case 5:
|
||||||
cardImageSource = AltMtgOnlTokensImageSource.getInstance();
|
cardImageSource = AltMtgOnlTokensImageSource.getInstance();
|
||||||
break;
|
break;
|
||||||
|
case 6:
|
||||||
|
cardImageSource = GrabbagImageSource.getInstance();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
int count = DownloadPictures.this.cards.size();
|
int count = DownloadPictures.this.cards.size();
|
||||||
float mb = (count * cardImageSource.getAverageSize()) / 1024;
|
float mb = (count * cardImageSource.getAverageSize()) / 1024;
|
||||||
|
@ -508,7 +513,10 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
imageRef = cardImageSource.getSourceName() + imageRef;
|
imageRef = cardImageSource.getSourceName() + imageRef;
|
||||||
try {
|
try {
|
||||||
URL imageUrl = new URL(imageRef);
|
URL imageUrl = new URL(imageRef);
|
||||||
Runnable task = new DownloadTask(imageUrl, fileName, cardImageSource.getTotalImages());
|
if (card != null) {
|
||||||
|
card.setToken(cardImageSource.isTokenSource());
|
||||||
|
}
|
||||||
|
Runnable task = new DownloadTask(card, imageUrl, fileName, cardImageSource.getTotalImages());
|
||||||
executor.execute(task);
|
executor.execute(task);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
@ -567,8 +575,8 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
useSpecifiedPaths = false;
|
useSpecifiedPaths = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadTask(URL url, String actualFilename, int count) {
|
public DownloadTask(CardDownloadData card, URL url, String actualFilename, int count) {
|
||||||
this.card = null;
|
this.card = card;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
this.actualFilename = actualFilename;
|
this.actualFilename = actualFilename;
|
||||||
|
@ -588,10 +596,21 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
}
|
}
|
||||||
String imagePath;
|
String imagePath;
|
||||||
if (useSpecifiedPaths) {
|
if (useSpecifiedPaths) {
|
||||||
imagePath = CardImageUtils.getTokenBasePath();
|
if (card != null && card.isToken()) {
|
||||||
imagePath += actualFilename;
|
imagePath = CardImageUtils.getTokenBasePath() + actualFilename;;
|
||||||
String tmpFile = filePath + "ADDTOTOK" + actualFilename;
|
} else {
|
||||||
|
if (card != null) {
|
||||||
|
imagePath = CardImageUtils.getImageBasePath() + actualFilename;
|
||||||
|
} else {
|
||||||
|
imagePath = Constants.IO.imageBaseDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String tmpFile = filePath + "temporary" + actualFilename;
|
||||||
temporaryFile = new File(tmpFile.toString());
|
temporaryFile = new File(tmpFile.toString());
|
||||||
|
if (!temporaryFile.exists()) {
|
||||||
|
temporaryFile.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
imagePath = CardImageUtils.generateImagePath(card);
|
imagePath = CardImageUtils.generateImagePath(card);
|
||||||
}
|
}
|
||||||
|
@ -657,10 +676,12 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
graphics2D.dispose();
|
graphics2D.dispose();
|
||||||
writeImageToFile(renderedImage, outputFile);
|
writeImageToFile(renderedImage, outputFile);
|
||||||
} else {
|
} else {
|
||||||
|
outputFile.getParentFile().mkdirs();
|
||||||
new TFile(temporaryFile).cp_rp(outputFile);
|
new TFile(temporaryFile).cp_rp(outputFile);
|
||||||
}
|
}
|
||||||
temporaryFile.delete();
|
temporaryFile.delete();
|
||||||
} else {
|
} else {
|
||||||
|
outputFile.getParentFile().mkdirs();
|
||||||
new TFile(temporaryFile).cp_rp(outputFile);
|
new TFile(temporaryFile).cp_rp(outputFile);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -118,12 +118,17 @@ public class CardImageUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTokenBasePath() {
|
public static String getImageBasePath() {
|
||||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||||
String imagesPath = useDefault.equals("true") ? Constants.IO.imageBaseDir : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
String imagesPath = useDefault.equals("true") ? Constants.IO.imageBaseDir : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||||
if (!imagesPath.endsWith(TFile.separator)) {
|
if (!imagesPath.endsWith(TFile.separator)) {
|
||||||
imagesPath += TFile.separator;
|
imagesPath += TFile.separator;
|
||||||
}
|
}
|
||||||
|
return imagesPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getTokenBasePath() {
|
||||||
|
String imagesPath = getImageBasePath();
|
||||||
|
|
||||||
String finalPath = "";
|
String finalPath = "";
|
||||||
if (PreferencesDialog.isSaveImagesToZip()) {
|
if (PreferencesDialog.isSaveImagesToZip()) {
|
||||||
|
|
Loading…
Reference in a new issue