Commit 01f17916 authored by Michael Kamensky's avatar Michael Kamensky

Merge branch 'hqpicdownloader' into 'master'

Add Download HQ Card Pictures from Scryfall

See merge request !1983
parents 1c0736d7 1d8e7a0c
......@@ -28,6 +28,11 @@ public enum CSubmenuDownloaders implements ICDoc {
new GuiDownloader(new GuiDownloadPicturesLQ()).show();
}
};
private final UiCommand cmdPicDownloadHQ = new UiCommand() {
@Override public void run() {
new GuiDownloader(new GuiDownloadPicturesHQ()).show();
}
};
private final UiCommand cmdSetDownload = new UiCommand() {
@Override public void run() {
new GuiDownloader(new GuiDownloadSetPicturesLQ()).show();
......@@ -80,6 +85,7 @@ public enum CSubmenuDownloaders implements ICDoc {
public void initialize() {
final VSubmenuDownloaders view = VSubmenuDownloaders.SINGLETON_INSTANCE;
view.setDownloadPicsCommand(cmdPicDownload);
view.setDownloadPicsHQCommand(cmdPicDownloadHQ);
view.setDownloadSetPicsCommand(cmdSetDownload);
view.setDownloadQuestImagesCommand(cmdQuestImages);
view.setDownloadAchievementImagesCommand(cmdAchievementImages);
......
......@@ -57,6 +57,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
private final FLabel btnDownloadSetPics = _makeButton(localizer.getMessage("btnDownloadSetPics"));
private final FLabel btnDownloadPics = _makeButton(localizer.getMessage("btnDownloadPics"));
private final FLabel btnDownloadPicsHQ = _makeButton(localizer.getMessage("btnDownloadPicsHQ"));
private final FLabel btnDownloadQuestImages = _makeButton(localizer.getMessage("btnDownloadQuestImages"));
private final FLabel btnDownloadAchievementImages = _makeButton(localizer.getMessage("btnDownloadAchievementImages"));
private final FLabel btnReportBug = _makeButton(localizer.getMessage("btnReportBug"));
......@@ -82,6 +83,9 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
pnlContent.add(btnDownloadPics, constraintsBTN);
pnlContent.add(_makeLabel(localizer.getMessage("lblDownloadPics")), constraintsLBL);
pnlContent.add(btnDownloadPicsHQ, constraintsBTN);
pnlContent.add(_makeLabel(localizer.getMessage("lblDownloadPicsHQ")), constraintsLBL);
pnlContent.add(btnDownloadSetPics, constraintsBTN);
pnlContent.add(_makeLabel(localizer.getMessage("lblDownloadSetPics")), constraintsLBL);
......@@ -159,6 +163,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
}
public void setDownloadPicsCommand(UiCommand command) { btnDownloadPics.setCommand(command); }
public void setDownloadPicsHQCommand(UiCommand command) { btnDownloadPicsHQ.setCommand(command); }
public void setDownloadSetPicsCommand(UiCommand command) { btnDownloadSetPics.setCommand(command); }
public void setDownloadQuestImagesCommand(UiCommand command) { btnDownloadQuestImages.setCommand(command); }
public void setDownloadAchievementImagesCommand(UiCommand command) { btnDownloadAchievementImages.setCommand(command); }
......
......@@ -179,6 +179,7 @@ Achievements=Erfolge
# VSubmenuDownloaders.java
btnDownloadSetPics=Bilder(LQ) Sets herunterladen
btnDownloadPics=Bilder(LQ) Karten herunterladen
btnDownloadPicsHQ=Bilder(HQ) Karten herunterladen (Sehr langsam!)
btnDownloadQuestImages=Bilder für Quests herunterladen
btnDownloadAchievementImages=Bilder für Erfolge herunterladen
btnReportBug=Einen Fehler melden
......@@ -189,6 +190,7 @@ btnHowToPlay=Wie man spielt
btnDownloadPrices=Kartenpreise herunterladen
btnLicensing=Lizenzhinweis
lblDownloadPics=Lädt ein Standardbild pro Karte.
lblDownloadPicsHQ=Lädt ein Standardbild (HQ) pro Karte.
lblDownloadSetPics=Lädt alle Bilder pro Karte. Eines für jedes Set, in welchem die Karte auftauchte.
lblDownloadQuestImages=Lädt die Bilder für den Quest-Modus.
lblDownloadAchievementImages=Lädt die Bilder zu den möglichen Erfolgen. Verschönert die Trophäensammlung.
......
......@@ -178,6 +178,7 @@ KeyboardShortcuts=Keyboard Shortcuts
Achievements=Achievements
# VSubmenuDownloaders.java
btnDownloadSetPics=Download LQ Set Pictures
btnDownloadPicsHQ=Download HQ Card Pictures (Very Slow!)
btnDownloadPics=Download LQ Card Pictures
btnDownloadQuestImages=Download Quest Images
btnDownloadAchievementImages=Download Achievement Images
......@@ -189,6 +190,7 @@ btnHowToPlay=How To Play
btnDownloadPrices=Download Card Prices
btnLicensing=License Details
lblDownloadPics=Download default card picture for each card.
lblDownloadPicsHQ=Download default card HQ picture for each card.
lblDownloadSetPics=Download all pictures of each card (one for each set the card appeared in)
lblDownloadQuestImages=Download tokens and icons used in Quest mode.
lblDownloadAchievementImages=Download achievement images to really make your trophies stand out.
......
......@@ -179,6 +179,7 @@ Achievements=Logros
# VSubmenuDownloaders.java
btnDownloadSetPics=Descargar todos los Sets de Cartas
btnDownloadPics=Descargar todas las Cartas
btnDownloadPicsHQ=Descargar todas las Cartas en calidad alta (Muy lento!)
btnDownloadQuestImages=Descargar Imágenes del modo Quest
btnDownloadAchievementImages=Descagar Imágenes de los Logros
btnReportBug=Reportar un error
......@@ -189,6 +190,7 @@ btnHowToPlay=Cómo jugar (Inglés)
btnDownloadPrices=Descargar los precios de las cartas
btnLicensing=Detalles de la licencia
lblDownloadPics=Descargar la imagen de la carta por defecto para cada carta.
lblDownloadPicsHQ=Descargar la imagen en calidad alta de la carta por defecto para cada carta.
lblDownloadSetPics=Descargue todas las imágenes de cada carta (una por cada set donde apareció la carta)
lblDownloadQuestImages=Descarga fichas e íconos utilizados en el modo Quest.
lblDownloadAchievementImages=Descarga imágenes de logros para que tus trofeos realmente destaquen.
......
......@@ -32,6 +32,7 @@ import java.net.URLDecoder;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -272,7 +273,13 @@ public abstract class GuiDownloadService implements Runnable {
URL imageUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection(p);
// don't allow redirections here -- they indicate 'file not found' on the server
conn.setInstanceFollowRedirects(false);
// only allow redirections to consume Scryfall API
if(url.contains("api.scryfall.com")) {
conn.setInstanceFollowRedirects(true);
TimeUnit.MILLISECONDS.sleep(100);
} else {
conn.setInstanceFollowRedirects(false);
}
conn.connect();
// if file is not found and this is a JPG, give PNG a shot...
......
......@@ -284,6 +284,8 @@ public final class ForgeConstants {
public static final String URL_PIC_DOWNLOAD = URL_CARDFORGE + "/images/cards/";
public static final String URL_TOKEN_DOWNLOAD = URL_CARDFORGE + "/images/tokens/";
public static final String URL_PRICE_DOWNLOAD = URL_CARDFORGE + "/all-prices.txt";
private static final String URL_SCRYFALL = "https://api.scryfall.com";
public static final String URL_PIC_SCRYFALL_DOWNLOAD = URL_SCRYFALL + "/cards/";
// Constants for Display Card Identity game setting
public static final String DISP_CURRENT_COLORS_ALWAYS = "Always";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment