Merge pull request #8193 from kevlahnota/master2

fix planechase bg download
This commit is contained in:
kevlahnota
2025-07-25 00:47:20 +08:00
committed by GitHub
2 changed files with 21 additions and 10 deletions

View File

@@ -37,7 +37,8 @@ public class LibGDXImageFetcher extends ImageFetcher {
String newdespath = urlToDownload.contains(".fullborder.") || urlToDownload.startsWith(ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD) ? String newdespath = urlToDownload.contains(".fullborder.") || urlToDownload.startsWith(ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD) ?
TextUtil.fastReplace(destPath, ".full.", ".fullborder.") : destPath; 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 newdespath = newdespath.replace(".jpg", ".fullborder.jpg"); //fix planes/phenomenon for round border options
URL url = new URL(urlToDownload); URL url = new URL(urlToDownload);
System.out.println("Attempting to fetch: " + url); System.out.println("Attempting to fetch: " + url);
@@ -83,10 +84,10 @@ public class LibGDXImageFetcher extends ImageFetcher {
public void run() { public void run() {
boolean success = false; boolean success = false;
for (String urlToDownload : downloadUrls) { for (String urlToDownload : downloadUrls) {
boolean isPlanechaseBG = urlToDownload.startsWith("https://downloads.cardforge.org/images/planes/"); boolean isPlanechaseBG = urlToDownload.startsWith("PLANECHASEBG:");
try { try {
success = doFetch(urlToDownload); success = doFetch(urlToDownload.replace("PLANECHASEBG:", ""));
if (success) { if (success) {
break; break;

View File

@@ -116,13 +116,22 @@ public abstract class ImageFetcher {
final ArrayList<String> downloadUrls = new ArrayList<>(); final ArrayList<String> downloadUrls = new ArrayList<>();
if (imageKey.startsWith("PLANECHASEBG:")) { if (imageKey.startsWith("PLANECHASEBG:")) {
final String filename = imageKey.substring("PLANECHASEBG:".length()); final String filename = imageKey.substring("PLANECHASEBG:".length());
downloadUrls.add("https://downloads.cardforge.org/images/planes/" + filename); PaperCard pc = StaticData.instance().getVariantCards().getCard(filename.replace("_", " ").replace(".jpg", ""));
FileUtil.ensureDirectoryExists(ForgeConstants.CACHE_PLANECHASE_PICS_DIR); if (pc != null) {
File destFile = new File(ForgeConstants.CACHE_PLANECHASE_PICS_DIR, filename); CardEdition ed = StaticData.instance().getEditions().get(pc.getEdition());
if (destFile.exists()) if (ed != null) {
return; 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; return;
} }
@@ -266,7 +275,8 @@ public abstract class ImageFetcher {
return; return;
if (tempdata.length < 2) { 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; return;
} }