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