mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
download .fullborder images if .full is not found
This commit is contained in:
@@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import forge.util.TextUtil;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
@@ -257,6 +258,7 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
for (Entry<String, String> kv : files.entrySet()) {
|
||||
boolean isJPG = true;
|
||||
boolean isLogged = false;
|
||||
boolean fullborder = false;
|
||||
if (cancel) {//stop prevent sleep
|
||||
GuiBase.getInterface().preventSystemSleep(false);
|
||||
break; }
|
||||
@@ -266,7 +268,7 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
String url = kv.getValue();
|
||||
|
||||
String decodedKey = decodeURL(kv.getKey());
|
||||
final File fileDest = new File(decodedKey);
|
||||
File fileDest = new File(decodedKey);
|
||||
final String filePath = fileDest.getPath();
|
||||
final String subLastIndex = filePath.contains("pics") ? "\\pics\\" : "\\db\\";
|
||||
|
||||
@@ -288,9 +290,22 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
}
|
||||
conn.connect();
|
||||
|
||||
//if .full file is not found try fullborder
|
||||
if ((conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) && (url.contains(".full.jpg")))
|
||||
{
|
||||
fullborder = true;
|
||||
conn.disconnect();
|
||||
url = TextUtil.fastReplace(url, ".full.jpg", ".fullborder.jpg");
|
||||
imageUrl = new URL(url);
|
||||
conn = (HttpURLConnection) imageUrl.openConnection(p);
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
conn.connect();
|
||||
}
|
||||
|
||||
// if file is not found and this is a JPG, give PNG a shot...
|
||||
if ((conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) && (url.endsWith(".jpg")))
|
||||
{
|
||||
fullborder = false;
|
||||
isJPG = false;
|
||||
conn.disconnect();
|
||||
if(url.contains("/images/")){
|
||||
@@ -304,6 +319,10 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
conn.connect();
|
||||
}
|
||||
|
||||
if (fullborder) {
|
||||
fileDest = new File(TextUtil.fastReplace(decodedKey, ".full.jpg", ".fullborder.jpg"));
|
||||
}
|
||||
|
||||
switch (conn.getResponseCode()) {
|
||||
case HttpURLConnection.HTTP_OK:
|
||||
fos = new FileOutputStream(fileDest);
|
||||
|
||||
Reference in New Issue
Block a user