Set socket timeout on Android Downloader and fixed some minor exceptions.
This commit is contained in:
@@ -145,6 +145,11 @@ public class ImgDownloader {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
|
httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
|
||||||
|
httpcon.setConnectTimeout(5000);
|
||||||
|
httpcon.setReadTimeout(5000);
|
||||||
|
httpcon.setAllowUserInteraction(false);
|
||||||
|
httpcon.setDoInput(true);
|
||||||
|
httpcon.setDoOutput(false);
|
||||||
InputStream in;
|
InputStream in;
|
||||||
try {
|
try {
|
||||||
in = new BufferedInputStream(httpcon.getInputStream());
|
in = new BufferedInputStream(httpcon.getInputStream());
|
||||||
@@ -208,20 +213,23 @@ public class ImgDownloader {
|
|||||||
FileOutputStream fos = new FileOutputStream(cardimage);
|
FileOutputStream fos = new FileOutputStream(cardimage);
|
||||||
fos.write(response);
|
fos.write(response);
|
||||||
fos.close();
|
fos.close();
|
||||||
Bitmap yourBitmap = BitmapFactory.decodeFile(cardimage);
|
|
||||||
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, ImgX, ImgY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmap = BitmapFactory.decodeFile(cardimage);
|
||||||
|
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, ImgX, ImgY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(cardimage);
|
FileOutputStream fout = new FileOutputStream(cardimage);
|
||||||
resized.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resized.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.out.println("Warning: Problem resizing card: " + name + " (" + id + ".jpg) from " + imageurl + ", i will try with slow method...");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
Bitmap resizedThumb = Bitmap.createScaledBitmap(yourBitmap, ThumbX, ThumbY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmapThumb = BitmapFactory.decodeFile(cardimage);
|
||||||
|
Bitmap resizedThumb = Bitmap.createScaledBitmap(yourBitmapThumb, ThumbX, ThumbY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(thumbcardimage);
|
FileOutputStream fout = new FileOutputStream(thumbcardimage);
|
||||||
resizedThumb.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resizedThumb.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.out.println("Warning: Problem resizing card thumbnail: " + name + " (" + id + ".jpg) from " + imageurl + ", i will try with slow method...");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Warning: Problem fetching card: " + name + " (" + id + ".jpg) from " + imageurl + ", i will try with slow method...");
|
System.out.println("Warning: Problem fetching card: " + name + " (" + id + ".jpg) from " + imageurl + ", i will try with slow method...");
|
||||||
@@ -242,6 +250,11 @@ public class ImgDownloader {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
|
httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
|
||||||
|
httpcon.setConnectTimeout(5000);
|
||||||
|
httpcon.setReadTimeout(5000);
|
||||||
|
httpcon.setAllowUserInteraction(false);
|
||||||
|
httpcon.setDoInput(true);
|
||||||
|
httpcon.setDoOutput(false);
|
||||||
InputStream intoken;
|
InputStream intoken;
|
||||||
try {
|
try {
|
||||||
intoken = new BufferedInputStream(httpcon.getInputStream());
|
intoken = new BufferedInputStream(httpcon.getInputStream());
|
||||||
@@ -273,20 +286,23 @@ public class ImgDownloader {
|
|||||||
FileOutputStream fos2 = new FileOutputStream(tokenimage);
|
FileOutputStream fos2 = new FileOutputStream(tokenimage);
|
||||||
fos2.write(responsetoken);
|
fos2.write(responsetoken);
|
||||||
fos2.close();
|
fos2.close();
|
||||||
Bitmap yourBitmapToken = BitmapFactory.decodeFile(tokenimage);
|
|
||||||
Bitmap resizedToken = Bitmap.createScaledBitmap(yourBitmapToken, ImgX, ImgY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmapToken = BitmapFactory.decodeFile(tokenimage);
|
||||||
|
Bitmap resizedToken = Bitmap.createScaledBitmap(yourBitmapToken, ImgX, ImgY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(tokenimage);
|
FileOutputStream fout = new FileOutputStream(tokenimage);
|
||||||
resizedToken.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resizedToken.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.out.println("Warning: Problem resizing token: " + id + "t.jpg) from " + imageurl + ", i will try with slow method...");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
Bitmap resizedThumbToken = Bitmap.createScaledBitmap(yourBitmapToken, ThumbX, ThumbY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmapTokenThumb = BitmapFactory.decodeFile(tokenimage);
|
||||||
|
Bitmap resizedThumbToken = Bitmap.createScaledBitmap(yourBitmapTokenThumb, ThumbX, ThumbY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(tokenthumbimage);
|
FileOutputStream fout = new FileOutputStream(tokenthumbimage);
|
||||||
resizedThumbToken.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resizedThumbToken.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.out.println("Warning: Problem resizing token thumbnail: " + id + "t.jpg) from " + imageurl + ", i will try with slow method...");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Warning: Problem fetching token: " + id + "t.jpg from " + imageurl + ", i will try with slow method...");
|
System.out.println("Warning: Problem fetching token: " + id + "t.jpg from " + imageurl + ", i will try with slow method...");
|
||||||
@@ -484,6 +500,10 @@ public class ImgDownloader {
|
|||||||
cardurl = "https://deckmaster.info/images/cards/M15/-108-hr.jpg";
|
cardurl = "https://deckmaster.info/images/cards/M15/-108-hr.jpg";
|
||||||
else if (id.equals("74272"))
|
else if (id.equals("74272"))
|
||||||
cardurl = "https://img.scryfall.com/cards/large/front/4/5/45af7f55-9a69-43dd-969f-65411711b13e.jpg?1562487939";
|
cardurl = "https://img.scryfall.com/cards/large/front/4/5/45af7f55-9a69-43dd-969f-65411711b13e.jpg?1562487939";
|
||||||
|
else if(id.equals("378445t"))
|
||||||
|
cardurl = "https://deckmaster.info/images/cards/BNG/-11-hr.jpg";
|
||||||
|
else if(id.equals("378521t"))
|
||||||
|
cardurl = "https://deckmaster.info/images/cards/DDO/394383-hr.jpg";
|
||||||
else if (id.equals("687701"))
|
else if (id.equals("687701"))
|
||||||
cardurl = "https://deckmaster.info/images/cards/DKM/-2437-hr.jpg";
|
cardurl = "https://deckmaster.info/images/cards/DKM/-2437-hr.jpg";
|
||||||
else if (id.equals("687702"))
|
else if (id.equals("687702"))
|
||||||
@@ -1408,9 +1428,15 @@ public class ImgDownloader {
|
|||||||
HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
|
HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
|
||||||
if (httpcon == null) {
|
if (httpcon == null) {
|
||||||
System.err.println("Error: Problem fetching card: " + mappa.get(id) + "-" + id + ", i will not download it...");
|
System.err.println("Error: Problem fetching card: " + mappa.get(id) + "-" + id + ", i will not download it...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
|
httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
|
||||||
|
httpcon.setConnectTimeout(5000);
|
||||||
|
httpcon.setReadTimeout(5000);
|
||||||
|
httpcon.setAllowUserInteraction(false);
|
||||||
|
httpcon.setDoInput(true);
|
||||||
|
httpcon.setDoOutput(false);
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
try {
|
try {
|
||||||
in = new BufferedInputStream(httpcon.getInputStream());
|
in = new BufferedInputStream(httpcon.getInputStream());
|
||||||
@@ -1424,6 +1450,7 @@ public class ImgDownloader {
|
|||||||
in = new BufferedInputStream(url.openStream());
|
in = new BufferedInputStream(url.openStream());
|
||||||
} catch (Exception ex3) {
|
} catch (Exception ex3) {
|
||||||
System.err.println("Error: Problem downloading card: " + mappa.get(id) + " (" + id + ".jpg), i will not retry anymore...");
|
System.err.println("Error: Problem downloading card: " + mappa.get(id) + " (" + id + ".jpg), i will not retry anymore...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1442,20 +1469,23 @@ public class ImgDownloader {
|
|||||||
FileOutputStream fos = new FileOutputStream(cardimage);
|
FileOutputStream fos = new FileOutputStream(cardimage);
|
||||||
fos.write(response);
|
fos.write(response);
|
||||||
fos.close();
|
fos.close();
|
||||||
Bitmap yourBitmap = BitmapFactory.decodeFile(cardimage);
|
|
||||||
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, ImgX, ImgY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmap = BitmapFactory.decodeFile(cardimage);
|
||||||
|
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, ImgX, ImgY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(cardimage);
|
FileOutputStream fout = new FileOutputStream(cardimage);
|
||||||
resized.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resized.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.err.println("Warning: Problem resizing card: " + mappa.get(id) + " (" + id + ".jpg), image may be corrupted...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
}
|
}
|
||||||
Bitmap resizedThumb = Bitmap.createScaledBitmap(yourBitmap, ThumbX, ThumbY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmapthumb = BitmapFactory.decodeFile(cardimage);
|
||||||
|
Bitmap resizedThumb = Bitmap.createScaledBitmap(yourBitmapthumb, ThumbX, ThumbY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(thumbcardimage);
|
FileOutputStream fout = new FileOutputStream(thumbcardimage);
|
||||||
resizedThumb.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resizedThumb.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.err.println("Warning: Problem resizing card thumbnail: " + mappa.get(id) + " (" + id + ".jpg, image may be corrupted...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + "thumbnails" + File.separator + id + ".jpg\n" + res;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1472,17 +1502,20 @@ public class ImgDownloader {
|
|||||||
doc = Jsoup.connect(baseurl + id).get();
|
doc = Jsoup.connect(baseurl + id).get();
|
||||||
} catch (Exception e3) {
|
} catch (Exception e3) {
|
||||||
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + baseurl + id + ", i will not retry anymore...");
|
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + baseurl + id + ", i will not retry anymore...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doc == null) {
|
if (doc == null) {
|
||||||
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + baseurl + id + ", i can't download it...");
|
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + baseurl + id + ", i can't download it...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Elements divs = doc.select("body div");
|
Elements divs = doc.select("body div");
|
||||||
if (divs == null) {
|
if (divs == null) {
|
||||||
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + baseurl + id + ", i can't download it...");
|
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + baseurl + id + ", i can't download it...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1492,6 +1525,7 @@ public class ImgDownloader {
|
|||||||
break;
|
break;
|
||||||
if (k >= divs.size()) {
|
if (k >= divs.size()) {
|
||||||
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + baseurl + id + ", i can't download it...");
|
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + baseurl + id + ", i can't download it...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String cardname = divs.get(k + 1).childNode(0).attributes().get("#text").replace("\r\n", "").trim();
|
String cardname = divs.get(k + 1).childNode(0).attributes().get("#text").replace("\r\n", "").trim();
|
||||||
@@ -1526,6 +1560,7 @@ public class ImgDownloader {
|
|||||||
doc = Jsoup.connect(deckutrl + id).get();
|
doc = Jsoup.connect(deckutrl + id).get();
|
||||||
} catch (Exception e3) {
|
} catch (Exception e3) {
|
||||||
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + deckutrl + id + ", i will not retry anymore...");
|
System.err.println("Error: Problem reading card (" + mappa.get(id) + ") infos from: " + deckutrl + id + ", i will not retry anymore...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1612,6 +1647,7 @@ public class ImgDownloader {
|
|||||||
}
|
}
|
||||||
} catch (Exception e3) {
|
} catch (Exception e3) {
|
||||||
System.err.println("Error: Problem downloading card: " + mappa.get(id) + " (" + id + ".jpg), i will not retry anymore...");
|
System.err.println("Error: Problem downloading card: " + mappa.get(id) + " (" + id + ".jpg), i will not retry anymore...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1638,12 +1674,14 @@ public class ImgDownloader {
|
|||||||
|
|
||||||
if (doc == null) {
|
if (doc == null) {
|
||||||
System.err.println("Error: Problem fetching card: " + mappa.get(id) + " (" + id + ".jpg), i will not download it...");
|
System.err.println("Error: Problem fetching card: " + mappa.get(id) + " (" + id + ".jpg), i will not download it...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Elements imgs = doc.select("body img");
|
Elements imgs = doc.select("body img");
|
||||||
if (imgs == null) {
|
if (imgs == null) {
|
||||||
System.err.println("Error: Problem fetching card: " + mappa.get(id) + " (" + id + ".jpg), i will not download it...");
|
System.err.println("Error: Problem fetching card: " + mappa.get(id) + " (" + id + ".jpg), i will not download it...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1669,9 +1707,15 @@ public class ImgDownloader {
|
|||||||
HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
|
HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
|
||||||
if (httpcon == null) {
|
if (httpcon == null) {
|
||||||
System.err.println("Error: Problem fetching card: " + mappa.get(id) + " (" + id + ".jpg), i will not download it...");
|
System.err.println("Error: Problem fetching card: " + mappa.get(id) + " (" + id + ".jpg), i will not download it...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
|
httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
|
||||||
|
httpcon.setConnectTimeout(5000);
|
||||||
|
httpcon.setReadTimeout(5000);
|
||||||
|
httpcon.setAllowUserInteraction(false);
|
||||||
|
httpcon.setDoInput(true);
|
||||||
|
httpcon.setDoOutput(false);
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
try {
|
try {
|
||||||
in = new BufferedInputStream(httpcon.getInputStream());
|
in = new BufferedInputStream(httpcon.getInputStream());
|
||||||
@@ -1685,6 +1729,7 @@ public class ImgDownloader {
|
|||||||
in = new BufferedInputStream(httpcon.getInputStream());
|
in = new BufferedInputStream(httpcon.getInputStream());
|
||||||
} catch (IOException ex3) {
|
} catch (IOException ex3) {
|
||||||
System.err.println("Error: Problem downloading card: " + mappa.get(id) + " (" + id + ".jpg), i will not retry anymore...");
|
System.err.println("Error: Problem downloading card: " + mappa.get(id) + " (" + id + ".jpg), i will not retry anymore...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1703,21 +1748,23 @@ public class ImgDownloader {
|
|||||||
FileOutputStream fos = new FileOutputStream(cardimage);
|
FileOutputStream fos = new FileOutputStream(cardimage);
|
||||||
fos.write(response);
|
fos.write(response);
|
||||||
fos.close();
|
fos.close();
|
||||||
|
|
||||||
Bitmap yourBitmap = BitmapFactory.decodeFile(cardimage);
|
|
||||||
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, ImgX, ImgY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmap = BitmapFactory.decodeFile(cardimage);
|
||||||
|
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, ImgX, ImgY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(cardimage);
|
FileOutputStream fout = new FileOutputStream(cardimage);
|
||||||
resized.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resized.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.err.println("Warning: Problem resizing card: " + mappa.get(id) + " (" + id + ".jpg), image may be corrupted...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + id + ".jpg\n" + res;
|
||||||
}
|
}
|
||||||
Bitmap resizedThumb = Bitmap.createScaledBitmap(yourBitmap, ThumbX, ThumbY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmapthumb = BitmapFactory.decodeFile(cardimage);
|
||||||
|
Bitmap resizedThumb = Bitmap.createScaledBitmap(yourBitmapthumb, ThumbX, ThumbY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(thumbcardimage);
|
FileOutputStream fout = new FileOutputStream(thumbcardimage);
|
||||||
resizedThumb.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resizedThumb.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.err.println("Warning: Problem resizing card thumbnail: " + mappa.get(id) + " (" + id + ".jpg), image may be corrupted...");
|
||||||
|
res = mappa.get(id) + " - " + set + File.separator + "thumbnails" + File.separator + id + ".jpg\n" + res;
|
||||||
}
|
}
|
||||||
String text = "";
|
String text = "";
|
||||||
for (k = 0; k < divs.size(); k++)
|
for (k = 0; k < divs.size(); k++)
|
||||||
@@ -1917,6 +1964,7 @@ public class ImgDownloader {
|
|||||||
doc = Jsoup.connect(imageurl + scryset.toLowerCase()).get();
|
doc = Jsoup.connect(imageurl + scryset.toLowerCase()).get();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.err.println("Error: Problem occurring while searching for token: " + nametoken + " (" + id + "t.jpg), i will not download it...");
|
System.err.println("Error: Problem occurring while searching for token: " + nametoken + " (" + id + "t.jpg), i will not download it...");
|
||||||
|
res = nametoken + " - " + set + File.separator + id + "t.jpg\n" + res;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (doc == null)
|
if (doc == null)
|
||||||
@@ -1973,9 +2021,15 @@ public class ImgDownloader {
|
|||||||
HttpURLConnection httpcontoken = (HttpURLConnection) urltoken.openConnection();
|
HttpURLConnection httpcontoken = (HttpURLConnection) urltoken.openConnection();
|
||||||
if (httpcontoken == null) {
|
if (httpcontoken == null) {
|
||||||
System.err.println("Error: Problem downloading token: " + nametoken + " (" + id + "t.jpg), i will not download it...");
|
System.err.println("Error: Problem downloading token: " + nametoken + " (" + id + "t.jpg), i will not download it...");
|
||||||
|
res = nametoken + " - " + set + File.separator + id + "t.jpg\n" + res;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
httpcontoken.addRequestProperty("User-Agent", "Mozilla/4.76");
|
httpcontoken.addRequestProperty("User-Agent", "Mozilla/4.76");
|
||||||
|
httpcontoken.setConnectTimeout(5000);
|
||||||
|
httpcontoken.setReadTimeout(5000);
|
||||||
|
httpcontoken.setAllowUserInteraction(false);
|
||||||
|
httpcontoken.setDoInput(true);
|
||||||
|
httpcontoken.setDoOutput(false);
|
||||||
InputStream intoken = null;
|
InputStream intoken = null;
|
||||||
try {
|
try {
|
||||||
intoken = new BufferedInputStream(httpcontoken.getInputStream());
|
intoken = new BufferedInputStream(httpcontoken.getInputStream());
|
||||||
@@ -1989,6 +2043,7 @@ public class ImgDownloader {
|
|||||||
intoken = new BufferedInputStream(httpcontoken.getInputStream());
|
intoken = new BufferedInputStream(httpcontoken.getInputStream());
|
||||||
} catch (IOException ex3) {
|
} catch (IOException ex3) {
|
||||||
System.err.println("Error: Problem downloading token: " + nametoken + " (" + id + "t.jpg), i will not retry anymore...");
|
System.err.println("Error: Problem downloading token: " + nametoken + " (" + id + "t.jpg), i will not retry anymore...");
|
||||||
|
res = nametoken + " - " + set + File.separator + id + "t.jpg\n" + res;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2006,25 +2061,28 @@ public class ImgDownloader {
|
|||||||
String tokenthumbimage = thumbPath + File.separator + id + "t.jpg";
|
String tokenthumbimage = thumbPath + File.separator + id + "t.jpg";
|
||||||
if (!tokenfound && !id.equals("464007")) {
|
if (!tokenfound && !id.equals("464007")) {
|
||||||
System.err.println("Error: Problem downloading token: " + nametoken + " (" + id + "t.jpg) i will use the same image of its source card");
|
System.err.println("Error: Problem downloading token: " + nametoken + " (" + id + "t.jpg) i will use the same image of its source card");
|
||||||
|
res = nametoken + " - " + set + File.separator + id + "t.jpg\n" + res;
|
||||||
}
|
}
|
||||||
FileOutputStream fos2 = new FileOutputStream(tokenimage);
|
FileOutputStream fos2 = new FileOutputStream(tokenimage);
|
||||||
fos2.write(responsetoken);
|
fos2.write(responsetoken);
|
||||||
fos2.close();
|
fos2.close();
|
||||||
|
|
||||||
Bitmap yourBitmapToken = BitmapFactory.decodeFile(tokenimage);
|
|
||||||
Bitmap resizedToken = Bitmap.createScaledBitmap(yourBitmapToken, ImgX, ImgY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmapToken = BitmapFactory.decodeFile(tokenimage);
|
||||||
|
Bitmap resizedToken = Bitmap.createScaledBitmap(yourBitmapToken, ImgX, ImgY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(tokenimage);
|
FileOutputStream fout = new FileOutputStream(tokenimage);
|
||||||
resizedToken.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resizedToken.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.err.println("Warning: Problem resizing token: " + id + "t.jpg, image may be corrupted...");
|
||||||
|
res = nametoken + " - " + set + File.separator + "thumbnails" + File.separator + id + "t.jpg\n" + res;
|
||||||
}
|
}
|
||||||
Bitmap resizedThumbToken = Bitmap.createScaledBitmap(yourBitmapToken, ThumbX, ThumbY, true);
|
|
||||||
try {
|
try {
|
||||||
|
Bitmap yourBitmapTokenthumb = BitmapFactory.decodeFile(tokenimage);
|
||||||
|
Bitmap resizedThumbToken = Bitmap.createScaledBitmap(yourBitmapTokenthumb, ThumbX, ThumbY, true);
|
||||||
FileOutputStream fout = new FileOutputStream(tokenthumbimage);
|
FileOutputStream fout = new FileOutputStream(tokenthumbimage);
|
||||||
resizedThumbToken.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
resizedThumbToken.compress(Bitmap.CompressFormat.JPEG, 100, fout);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
System.err.println("Warning: Problem resizing token thumbnail: " + id + "t.jpg, image may be corrupted...");
|
||||||
|
res = nametoken + " - " + set + File.separator + "thumbnails" + File.separator + id + "t.jpg\n" + res;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user