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,7 +116,13 @@ 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", ""));
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); FileUtil.ensureDirectoryExists(ForgeConstants.CACHE_PLANECHASE_PICS_DIR);
File destFile = new File(ForgeConstants.CACHE_PLANECHASE_PICS_DIR, filename); File destFile = new File(ForgeConstants.CACHE_PLANECHASE_PICS_DIR, filename);
if (destFile.exists()) if (destFile.exists())
@@ -125,6 +131,9 @@ public abstract class ImageFetcher {
setupObserver(destFile.getAbsolutePath(), callback, downloadUrls); setupObserver(destFile.getAbsolutePath(), callback, downloadUrls);
return; return;
} }
}
return;
}
boolean useArtCrop = "Crop".equals(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_CARD_ART_FORMAT)); boolean useArtCrop = "Crop".equals(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_CARD_ART_FORMAT));
final String prefix = imageKey.substring(0, 2); final String prefix = imageKey.substring(0, 2);
@@ -266,6 +275,7 @@ public abstract class ImageFetcher {
return; return;
if (tempdata.length < 2) { if (tempdata.length < 2) {
if (!"planechase".equals(tempdata[0]))
System.err.println("Token image key is malformed: " + imageKey); System.err.println("Token image key is malformed: " + imageKey);
return; return;
} }