buildfix for VerifyCardDataTest. mtgjson file was moved, added a few fields, and requires adding a User-Agent to the request.

This commit is contained in:
John Hitchings 2018-12-20 17:02:48 -08:00
parent ad7ca19b56
commit 3d15325448
3 changed files with 8 additions and 1 deletions

View file

@ -47,4 +47,7 @@ class JsonCard {
public List<String> variations; public List<String> variations;
public String watermark; public String watermark;
public String tcgplayerProductId; public String tcgplayerProductId;
public String scryfallId;
public boolean isAlternative;
public String frameEffect;
} }

View file

@ -20,4 +20,5 @@ public class JsonToken {
public String uuid; public String uuid;
public String watermark; public String watermark;
public boolean isOnlineOnly; public boolean isOnlineOnly;
public String scryfallId;
} }

View file

@ -9,6 +9,7 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.text.Normalizer; import java.text.Normalizer;
@ -120,7 +121,9 @@ public final class MtgJson {
if (stream == null) { if (stream == null) {
File file = new File(filename); File file = new File(filename);
if (!file.exists()) { if (!file.exists()) {
InputStream download = new URL("http://mtgjson.com/v4/json/" + filename).openStream(); URLConnection connection = new URL("https://mtgjson.com/json/" + filename).openConnection();
connection.setRequestProperty("user-agent", "xmage");
InputStream download = connection.getInputStream();
Files.copy(download, file.toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(download, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
System.out.println("Downloaded " + filename + " to " + file.getAbsolutePath()); System.out.println("Downloaded " + filename + " to " + file.getAbsolutePath());
} else { } else {