.. | .. |
---|
1 | 1 | |
---|
2 | 2 | import java.io.*; |
---|
3 | 3 | import java.awt.*; |
---|
| 4 | +import java.net.URL; |
---|
4 | 5 | import java.util.zip.ZipInputStream; |
---|
5 | 6 | |
---|
6 | 7 | public class cTools |
---|
.. | .. |
---|
15 | 16 | |
---|
16 | 17 | java.net.URL u; |
---|
17 | 18 | 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 | + } |
---|
18 | 29 | |
---|
19 | 30 | java.util.zip.ZipInputStream zis; |
---|
20 | 31 | |
---|
.. | .. |
---|
39 | 50 | if (entryName.endsWith(".gsm")) |
---|
40 | 51 | { |
---|
41 | 52 | // ArchiCAD |
---|
42 | | - // continue; |
---|
| 53 | + continue; |
---|
43 | 54 | } |
---|
44 | 55 | |
---|
45 | 56 | if (entryName.endsWith(".max")) |
---|
46 | 57 | { |
---|
47 | 58 | // 3DS MAX |
---|
48 | | - // continue; |
---|
| 59 | + continue; |
---|
49 | 60 | } |
---|
50 | 61 | |
---|
51 | 62 | if (entryName.endsWith(".3ds") || entryName.endsWith(".obj")) |
---|
.. | .. |
---|
63 | 74 | // reading until read returns 0 or less. |
---|
64 | 75 | String outpath = location + "/" + entry.getName(); |
---|
65 | 76 | |
---|
| 77 | + //new java.io.File(outpath).mkdirs(); |
---|
| 78 | + |
---|
66 | 79 | TransferFile(outpath, zis); |
---|
67 | 80 | } |
---|
68 | 81 | } catch (java.net.MalformedURLException mue) |
---|
.. | .. |
---|
72 | 85 | //System.exit(2); |
---|
73 | 86 | } catch (IOException ioe) |
---|
74 | 87 | { |
---|
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(); |
---|
77 | 95 | //System.exit(3); |
---|
78 | 96 | } finally |
---|
79 | 97 | { |
---|
.. | .. |
---|
114 | 132 | modelName = modelName.substring(0, modelName.length() - 4); |
---|
115 | 133 | |
---|
116 | 134 | 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); |
---|
117 | 164 | } |
---|
118 | 165 | catch (Exception e) |
---|
119 | 166 | { |
---|
.. | .. |
---|
201 | 248 | GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", browser.getDirectory() + "/" + cat, id, name, icon); |
---|
202 | 249 | |
---|
203 | 250 | // To avoid network overload. |
---|
204 | | - Thread.sleep(2000); |
---|
| 251 | + Thread.sleep(1000); |
---|
205 | 252 | } |
---|
206 | 253 | |
---|
207 | 254 | file.close(); |
---|