mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Merge pull request #8193 from kevlahnota/master2
fix planechase bg download
This commit is contained in:
@@ -37,7 +37,8 @@ public class LibGDXImageFetcher extends ImageFetcher {
|
||||
|
||||
String newdespath = urlToDownload.contains(".fullborder.") || urlToDownload.startsWith(ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD) ?
|
||||
TextUtil.fastReplace(destPath, ".full.", ".fullborder.") : destPath;
|
||||
if (!newdespath.contains(".full") && urlToDownload.startsWith(ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD) && !destPath.startsWith(ForgeConstants.CACHE_TOKEN_PICS_DIR))
|
||||
if (!newdespath.contains(".full") && urlToDownload.startsWith(ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD) &&
|
||||
!destPath.startsWith(ForgeConstants.CACHE_TOKEN_PICS_DIR) && !destPath.startsWith(ForgeConstants.CACHE_PLANECHASE_PICS_DIR))
|
||||
newdespath = newdespath.replace(".jpg", ".fullborder.jpg"); //fix planes/phenomenon for round border options
|
||||
URL url = new URL(urlToDownload);
|
||||
System.out.println("Attempting to fetch: " + url);
|
||||
@@ -83,10 +84,10 @@ public class LibGDXImageFetcher extends ImageFetcher {
|
||||
public void run() {
|
||||
boolean success = false;
|
||||
for (String urlToDownload : downloadUrls) {
|
||||
boolean isPlanechaseBG = urlToDownload.startsWith("https://downloads.cardforge.org/images/planes/");
|
||||
boolean isPlanechaseBG = urlToDownload.startsWith("PLANECHASEBG:");
|
||||
try {
|
||||
|
||||
success = doFetch(urlToDownload);
|
||||
success = doFetch(urlToDownload.replace("PLANECHASEBG:", ""));
|
||||
|
||||
if (success) {
|
||||
break;
|
||||
|
||||
@@ -116,13 +116,22 @@ public abstract class ImageFetcher {
|
||||
final ArrayList<String> downloadUrls = new ArrayList<>();
|
||||
if (imageKey.startsWith("PLANECHASEBG:")) {
|
||||
final String filename = imageKey.substring("PLANECHASEBG:".length());
|
||||
downloadUrls.add("https://downloads.cardforge.org/images/planes/" + filename);
|
||||
FileUtil.ensureDirectoryExists(ForgeConstants.CACHE_PLANECHASE_PICS_DIR);
|
||||
File destFile = new File(ForgeConstants.CACHE_PLANECHASE_PICS_DIR, filename);
|
||||
if (destFile.exists())
|
||||
return;
|
||||
PaperCard pc = StaticData.instance().getVariantCards().getCard(filename.replace("_", " ").replace(".jpg", ""));
|
||||
if (pc != null) {
|
||||
CardEdition ed = StaticData.instance().getEditions().get(pc.getEdition());
|
||||
if (ed != null) {
|
||||
String setCode = ed.getScryfallCode();
|
||||
String langCode = ed.getCardsLangCode();
|
||||
downloadUrls.add("PLANECHASEBG:" + ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD + ImageUtil.getScryfallDownloadUrl(pc, "", setCode, langCode, true));
|
||||
FileUtil.ensureDirectoryExists(ForgeConstants.CACHE_PLANECHASE_PICS_DIR);
|
||||
File destFile = new File(ForgeConstants.CACHE_PLANECHASE_PICS_DIR, filename);
|
||||
if (destFile.exists())
|
||||
return;
|
||||
|
||||
setupObserver(destFile.getAbsolutePath(), callback, downloadUrls);
|
||||
setupObserver(destFile.getAbsolutePath(), callback, downloadUrls);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -266,7 +275,8 @@ public abstract class ImageFetcher {
|
||||
return;
|
||||
|
||||
if (tempdata.length < 2) {
|
||||
System.err.println("Token image key is malformed: " + imageKey);
|
||||
if (!"planechase".equals(tempdata[0]))
|
||||
System.err.println("Token image key is malformed: " + imageKey);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user