mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Grab LQ picture from primary server
This commit is contained in:
@@ -231,7 +231,11 @@ public final class CardRules implements ICardCharacteristics {
|
|||||||
// Downloadable image
|
// Downloadable image
|
||||||
private String dlUrl;
|
private String dlUrl;
|
||||||
private String dlUrlOtherSide;
|
private String dlUrlOtherSide;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getPictureUrl(boolean backface ) { return backface ? dlUrlOtherSide : dlUrl; }
|
public String getPictureUrl(boolean backface ) { return backface ? dlUrlOtherSide : dlUrl; }
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setDlUrls(String[] dlUrls) { this.dlUrl = dlUrls[0]; this.dlUrlOtherSide = dlUrls[1]; }
|
public void setDlUrls(String[] dlUrls) { this.dlUrl = dlUrls[0]; this.dlUrlOtherSide = dlUrls[1]; }
|
||||||
|
|
||||||
public ColorSet getColorIdentity() {
|
public ColorSet getColorIdentity() {
|
||||||
|
|||||||
@@ -119,37 +119,6 @@ public class ImageUtil {
|
|||||||
return getImageRelativePath(cp, backFace, true, true);
|
return getImageRelativePath(cp, backFace, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getDownloadUrlAndDestination(String cacheCardPicsDir, PaperCard c, boolean backFace) {
|
|
||||||
final CardRules cardRules = c.getRules();
|
|
||||||
final String urls = cardRules.getPictureUrl(backFace);
|
|
||||||
if (StringUtils.isEmpty(urls)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String filename = ImageUtil.getImageKey(c, backFace, false);
|
|
||||||
final File destFile = new File(cacheCardPicsDir, filename + ".jpg");
|
|
||||||
if (destFile.exists()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
filename = destFile.getAbsolutePath();
|
|
||||||
|
|
||||||
final String urlToDownload;
|
|
||||||
int urlIndex = 0;
|
|
||||||
int allUrlsLen = 1;
|
|
||||||
if (!urls.contains("\\")) {
|
|
||||||
urlToDownload = urls;
|
|
||||||
} else {
|
|
||||||
final String[] allUrls = urls.split("\\\\");
|
|
||||||
allUrlsLen = allUrls.length;
|
|
||||||
urlIndex = (c.getArtIndex()-1) % allUrlsLen;
|
|
||||||
urlToDownload = allUrls[urlIndex];
|
|
||||||
}
|
|
||||||
// System.out.println(c.getName() + "|" + c.getEdition() + " - " + c.getArtIndex() + " -> " + urlIndex + "/" + allUrlsLen + " === " + filename + " <<< " + urlToDownload);
|
|
||||||
|
|
||||||
return new String[] { urlToDownload, filename };
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toMWSFilename(String in) {
|
public static String toMWSFilename(String in) {
|
||||||
final StringBuilder out = new StringBuilder();
|
final StringBuilder out = new StringBuilder();
|
||||||
char c;
|
char c;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import forge.model.FModel;
|
|||||||
import forge.properties.ForgeConstants;
|
import forge.properties.ForgeConstants;
|
||||||
import forge.util.ImageUtil;
|
import forge.util.ImageUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
@@ -53,15 +54,16 @@ public class GuiDownloadPicturesLQ extends GuiDownloadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addDLObject(final PaperCard c, final Map<String, String> downloads, final boolean backFace) {
|
private static void addDLObject(final PaperCard c, final Map<String, String> downloads, final boolean backFace) {
|
||||||
String[] result = ImageUtil.getDownloadUrlAndDestination(ForgeConstants.CACHE_CARD_PICS_DIR, c, backFace);
|
final String destPath = ForgeConstants.CACHE_CARD_PICS_DIR + ImageUtil.getImageKey(c, backFace, false);
|
||||||
if (result == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final String urlToDownload = result[0];
|
|
||||||
final String destPath = result[1];
|
|
||||||
if (downloads.containsKey(destPath)) {
|
if (downloads.containsKey(destPath)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
downloads.put(destPath, urlToDownload);
|
|
||||||
|
File destFile = new File(destPath);
|
||||||
|
if (destFile.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
downloads.put(destPath, ForgeConstants.URL_PIC_DOWNLOAD + ImageUtil.getDownloadUrl(c, backFace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user