forked from External/mage
download: reworked scryfall images support:
- download: fixed unmount zip errors on cancel download in some use cases (closes #12536); - download: significant download speed improvements (now it depends on user's network speed, not api limitations); - download: added additional error dialogs on bad use cases; - scryfall: added cards and bulk data api support; - scryfall: added bulk data download (updates once per week, contains all scryfall cards and store in images\downloading folder, 2 GB size); - scryfall: added optimized images download without api usage (use direct images links from bulk data, closes #11576); - scryfall: improved image source searching for some use cases (miss or wrong images problems, closes #12511); - scryfall: tokens don't use bulk data; - scryfall: 75k small images downloads 40 minutes and takes 1 GB and 2100 api calls (most of it from tokens); - scryfall: how-to disable bulk data, e.g. for api testing: -Dxmage.scryfallEnableBulkData=false
This commit is contained in:
parent
46f7304692
commit
0a55e37c8c
19 changed files with 884 additions and 216 deletions
|
|
@ -1355,7 +1355,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
userRequestDialog.showDialog(userRequestMessage);
|
||||
}
|
||||
|
||||
public void showErrorDialog(String errorType, Exception e) {
|
||||
public void showErrorDialog(String errorType, Throwable e) {
|
||||
String errorMessage = e.getMessage();
|
||||
if (errorMessage == null || errorMessage.isEmpty() || errorMessage.equals("Null")) {
|
||||
errorMessage = e.getClass().getSimpleName() + " - look at server or client logs for more details";
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@
|
|||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/search_24.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Fast search your flag"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Search set to download"/>
|
||||
<Property name="alignmentX" type="float" value="1.0"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[25, 25]"/>
|
||||
|
|
@ -419,7 +419,7 @@
|
|||
<SubComponents>
|
||||
<Component class="javax.swing.JCheckBox" name="checkboxRedownload">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="<html>Re-download all images"/>
|
||||
<Property name="text" type="java.lang.String" value="<html>Re-download all selected images"/>
|
||||
<Property name="verticalAlignment" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ public class DownloadImagesDialog extends MageDialog {
|
|||
panelModeSelect.add(fillerMode1);
|
||||
|
||||
buttonSearchSet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_24.png"))); // NOI18N
|
||||
buttonSearchSet.setToolTipText("Fast search your flag");
|
||||
buttonSearchSet.setToolTipText("Search set to download");
|
||||
buttonSearchSet.setAlignmentX(1.0F);
|
||||
buttonSearchSet.setPreferredSize(new java.awt.Dimension(25, 25));
|
||||
buttonSearchSet.addActionListener(new java.awt.event.ActionListener() {
|
||||
|
|
@ -378,7 +378,7 @@ public class DownloadImagesDialog extends MageDialog {
|
|||
panelRedownload.setPreferredSize(new java.awt.Dimension(280, 100));
|
||||
panelRedownload.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
checkboxRedownload.setText("<html>Re-download all images");
|
||||
checkboxRedownload.setText("<html>Re-download all selected images");
|
||||
checkboxRedownload.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
|
||||
panelRedownload.add(checkboxRedownload, java.awt.BorderLayout.CENTER);
|
||||
panelRedownload.add(filler1, java.awt.BorderLayout.PAGE_END);
|
||||
|
|
@ -444,6 +444,7 @@ public class DownloadImagesDialog extends MageDialog {
|
|||
}//GEN-LAST:event_buttonStopActionPerformed
|
||||
|
||||
private void doClose(int retStatus) {
|
||||
|
||||
returnStatus = retStatus;
|
||||
setVisible(false);
|
||||
dispose();
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public class XmageURLConnection {
|
|||
Proxy proxy = null;
|
||||
HttpURLConnection connection = null;
|
||||
HttpLoggingType loggingType = HttpLoggingType.ERRORS;
|
||||
boolean forceGZipEncoding = false;
|
||||
|
||||
public XmageURLConnection(String url) {
|
||||
this.url = url;
|
||||
|
|
@ -75,6 +76,10 @@ public class XmageURLConnection {
|
|||
}
|
||||
}
|
||||
|
||||
public void setForceGZipEncoding(boolean enable) {
|
||||
this.forceGZipEncoding = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
|
|
@ -130,7 +135,11 @@ public class XmageURLConnection {
|
|||
}
|
||||
|
||||
private void initDefaultHeaders() {
|
||||
// warning, do not add Accept-Encoding - it processing inside URLConnection for http/https links (trying to use gzip by default)
|
||||
// warning, Accept-Encoding processing inside URLConnection for http/https links (trying to use gzip by default)
|
||||
// use force encoding for special use cases (example: download big text file as zip file)
|
||||
if (forceGZipEncoding) {
|
||||
this.connection.setRequestProperty("Accept-Encoding", "gzip");
|
||||
}
|
||||
|
||||
// user agent due standard notation User-Agent: <product> / <product-version> <comment>
|
||||
// warning, dot not add os, language and other details
|
||||
|
|
@ -290,13 +299,18 @@ public class XmageURLConnection {
|
|||
return "";
|
||||
}
|
||||
|
||||
public static InputStream downloadBinary(String resourceUrl) {
|
||||
return downloadBinary(resourceUrl, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fast download of binary data
|
||||
*
|
||||
* @return stream on OK 200 response or null on any other errors
|
||||
*/
|
||||
public static InputStream downloadBinary(String resourceUrl) {
|
||||
public static InputStream downloadBinary(String resourceUrl, boolean downloadAsGZip) {
|
||||
XmageURLConnection con = new XmageURLConnection(resourceUrl);
|
||||
con.setForceGZipEncoding(downloadAsGZip);
|
||||
con.startConnection();
|
||||
if (con.isConnected()) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue