Reroute card images to scryfall.

Don't try to redownload if it fails during a session
This commit is contained in:
Chris H
2025-02-23 12:07:44 -05:00
parent 0a15a0352d
commit f84f694351
4 changed files with 47 additions and 16 deletions

View File

@@ -29,7 +29,12 @@ public class LibGDXImageFetcher extends ImageFetcher {
this.notifyObservers = notifyObservers;
}
private void doFetch(String urlToDownload) throws IOException {
private boolean doFetch(String urlToDownload) throws IOException {
if (disableHostedDownload && urlToDownload.startsWith(ForgeConstants.URL_CARDFORGE) && !urlToDownload.contains("tokens")) {
// Don't try to download card images from cardforge servers
return false;
}
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))
@@ -54,6 +59,7 @@ public class LibGDXImageFetcher extends ImageFetcher {
System.out.println("Saved image to " + newdespath);
GuiBase.getInterface().invokeInEdtLater(notifyObservers);
return true;
}
private String tofullBorder(String imageurl) {
@@ -75,14 +81,16 @@ 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/");
try {
if (isPlanechaseBG) {
doFetch(urlToDownload);
break;
success = doFetch(urlToDownload);
} else {
doFetch(tofullBorder(urlToDownload));
success = doFetch(tofullBorder(urlToDownload));
}
if (success) {
break;
}
} catch (IOException e) {
@@ -97,8 +105,10 @@ public class LibGDXImageFetcher extends ImageFetcher {
String extension = urlToDownload.substring(typeIndex);
urlToDownload = setlessFilename + extension;
try {
doFetch(tofullBorder(urlToDownload));
break;
success = doFetch(tofullBorder(urlToDownload));
if (success) {
break;
}
} catch (IOException t) {
System.out.println("Failed to download setless token [" + destPath + "]: " + e.getMessage());
}