forked from michaljaz/webmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitems.js
More file actions
52 lines (44 loc) · 1.46 KB
/
items.js
File metadata and controls
52 lines (44 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Generated by CoffeeScript 2.5.1
(function() {
var JSSoup, fs, http, https, options, request;
request = require('request');
JSSoup = require('jssoup').default;
fs = require('fs');
http = require("http");
https = require("https");
options = {
method: 'GET',
url: "https://www.digminecraft.com/lists/item_id_list_pc.php",
encoding: "utf-8"
};
request(options, function(err, response, body) {
var i, j, k, l, last, len, map, ref, ref1, soup, title, type, war;
soup = new JSSoup(body);
map = {};
last = null;
ref = soup.findAll("td");
for (k = 0, len = ref.length; k < len; k++) {
i = ref[k];
if ((i.text !== " ") && (i.text.includes("minecraft:"))) {
title = i.text.split("(")[0];
war = 0;
for (j = l = 0, ref1 = i.text.length - 1; (0 <= ref1 ? l <= ref1 : l >= ref1); j = 0 <= ref1 ? ++l : --l) {
if (i.text[j] === "(") {
war = j;
}
}
type = (i.text.substr(war + 11)).split(")")[0];
console.log(type, last);
(function(type, url) {
var file;
file = fs.createWriteStream(`${__dirname}/client/assets/items/${type}.png`);
return https.get(url, function(response) {
return response.pipe(file);
});
})(type, `https://www.digminecraft.com${last}`);
} else if (i.find("img") !== void 0) {
last = i.find("img").attrs["data-src"];
}
}
});
}).call(this);