mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28: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
|
||||
private String dlUrl;
|
||||
private String dlUrlOtherSide;
|
||||
|
||||
@Deprecated
|
||||
public String getPictureUrl(boolean backface ) { return backface ? dlUrlOtherSide : dlUrl; }
|
||||
|
||||
@Deprecated
|
||||
public void setDlUrls(String[] dlUrls) { this.dlUrl = dlUrls[0]; this.dlUrlOtherSide = dlUrls[1]; }
|
||||
|
||||
public ColorSet getColorIdentity() {
|
||||
|
||||
@@ -118,37 +118,6 @@ public class ImageUtil {
|
||||
public static String getDownloadUrl(PaperCard cp, boolean backFace) {
|
||||
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) {
|
||||
final StringBuilder out = new StringBuilder();
|
||||
|
||||
@@ -22,6 +22,7 @@ import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.ImageUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
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) {
|
||||
String[] result = ImageUtil.getDownloadUrlAndDestination(ForgeConstants.CACHE_CARD_PICS_DIR, c, backFace);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
final String urlToDownload = result[0];
|
||||
final String destPath = result[1];
|
||||
final String destPath = ForgeConstants.CACHE_CARD_PICS_DIR + ImageUtil.getImageKey(c, backFace, false);
|
||||
if (downloads.containsKey(destPath)) {
|
||||
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