Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

56
LINES

< > BotCompany Repo | #1010484 // Diagrams Downloader

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (9284L/63K).

1  
!7
2  
3  
concept FileMeta {
4  
  int fileID;
5  
  S md5;
6  
  long checked;
7  
}
8  
9  
svoid init {
10  
  dbIndexing(FileMeta, 'fileID);
11  
}
12  
13  
p { 
14  
  init();
15  
  typicalDownload();
16  
}
17  
18  
svoid fullDownload {
19  
  download(diagramServer_IDsAndMD5s());
20  
}
21  
22  
svoid typicalDownload {
23  
  SS map = diagramServer_typicalSet();
24  
  download(map);
25  
  saveTextFile(getProgramFile("typical.structure"), struct(map));
26  
}
27  
28  
svoid downloadLatestFileNamed(S name) {
29  
  L l = (L) safeUnstructure(loadPage("http://ai1.lol/1010474/raw/latest-file-named/" + urlencode(name)));
30  
  if (l == null) ret with print("Can't file named " + name + " on diagram server");
31  
  S md5;
32  
  download(litmap(str(first(l)), md5 = second(l))); // ID + MD5
33  
  saveTextFile(getProgramFile(urlencode(name) + ".file"), md5);
34  
}
35  
36  
// map: ID -> MD5
37  
svoid download(SS map) {
38  
  loading "Downloading diagrams..." {
39  
  pnl(map);
40  
  for (S id : keys(map)) {
41  
    S md5 = map.get(id);
42  
    FileMeta m = uniq(FileMeta, fileID := parseInt(id));
43  
    cset(m, +md5, checked := now());
44  
    File f = getFile(m);
45  
    if (!f.exists()) {
46  
      S url = diagramServer_idToURL(id);
47  
      saveBinaryFile(f, loadBinaryPage(url));
48  
      print("Saved " + f);
49  
    }
50  
  }
51  
  print("Done.");
52  
}}
53  
54  
static File getFile(FileMeta m) {
55  
  ret getProgramFile(m.md5);
56  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, imzmzdywqqli, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1010484
Snippet name: Diagrams Downloader
Eternal ID of this version: #1010484/15
Text MD5: 0b62130399dba5702bed94ff61e319de
Transpilation MD5: 1751701720a3dbb4bb43554ea409bdfe
Author: stefan
Category: javax / networking
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-16 22:48:47
Source code size: 1288 bytes / 56 lines
Pitched / IR pitched: No / No
Views / Downloads: 604 / 3263
Version history: 14 change(s)
Referenced in: [show references]