Normand Briere
2019-11-17 cb37a129d1adb403019c96e798e86e2da9667f15
cTools.java
....@@ -1,6 +1,7 @@
11
22 import java.io.*;
33 import java.awt.*;
4
+import java.net.URL;
45 import java.util.zip.ZipInputStream;
56
67 public class cTools
....@@ -15,6 +16,16 @@
1516
1617 java.net.URL u;
1718 InputStream is = null;
19
+
20
+ if (new File(location).exists())
21
+ {
22
+ // Already downloaded
23
+ System.out.println(location + ": Already downloaded");
24
+
25
+ GetIcon(icon, location, "icon");
26
+
27
+ return;
28
+ }
1829
1930 java.util.zip.ZipInputStream zis;
2031
....@@ -39,13 +50,13 @@
3950 if (entryName.endsWith(".gsm"))
4051 {
4152 // ArchiCAD
42
- // continue;
53
+ continue;
4354 }
4455
4556 if (entryName.endsWith(".max"))
4657 {
4758 // 3DS MAX
48
- // continue;
59
+ continue;
4960 }
5061
5162 if (entryName.endsWith(".3ds") || entryName.endsWith(".obj"))
....@@ -63,6 +74,8 @@
6374 // reading until read returns 0 or less.
6475 String outpath = location + "/" + entry.getName();
6576
77
+ //new java.io.File(outpath).mkdirs();
78
+
6679 TransferFile(outpath, zis);
6780 }
6881 } catch (java.net.MalformedURLException mue)
....@@ -72,8 +85,13 @@
7285 //System.exit(2);
7386 } catch (IOException ioe)
7487 {
75
- //System.err.println("Oops - an IOException happened.");
76
- //ioe.printStackTrace();
88
+ System.err.println("Oops - an IOException happened.");
89
+ ioe.printStackTrace();
90
+ //System.exit(3);
91
+ } catch (IllegalArgumentException iae)
92
+ {
93
+ System.err.println("Oops - an IllegalArgumentException happened.");
94
+ iae.printStackTrace();
7795 //System.exit(3);
7896 } finally
7997 {
....@@ -114,6 +132,35 @@
114132 modelName = modelName.substring(0, modelName.length() - 4);
115133
116134 TransferFile(location + "/" + modelName + ".jpg", is);
135
+
136
+ GetIcon(icon, location, "icon");
137
+ }
138
+ catch (Exception e)
139
+ {
140
+ e.printStackTrace();
141
+ }
142
+ }
143
+
144
+ private static void GetIcon(String icon, String location, String iconName)
145
+ {
146
+ URL u;
147
+ InputStream is;
148
+ try
149
+ {
150
+ //icon = https://storage3d.com/storage/2008.08/resized/7142f85f2575b35078f15feddaf8b315_64x64.jpg
151
+
152
+ String[] split = icon.split("resized/");
153
+
154
+ icon = split[0] + split[1];
155
+
156
+ split = icon.split("_64x64");
157
+
158
+ icon = split[0] + ".jpg";
159
+
160
+ u = new java.net.URL(icon);
161
+ is = u.openStream();
162
+
163
+ TransferFile(location + "/" + iconName + ".jpg", is);
117164 }
118165 catch (Exception e)
119166 {
....@@ -201,7 +248,7 @@
201248 GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", browser.getDirectory() + "/" + cat, id, name, icon);
202249
203250 // To avoid network overload.
204
- Thread.sleep(2000);
251
+ Thread.sleep(1000);
205252 }
206253
207254 file.close();