mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Reroute card images to scryfall.
Don't try to redownload if it fails during a session
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user