forked from michaljaz/webmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitems.coffee
More file actions
67 lines (62 loc) · 1.7 KB
/
Copy pathitems.coffee
File metadata and controls
67 lines (62 loc) · 1.7 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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"
}
removeBg=()->
replaceColor = require 'replace-color'
fs=require "fs"
removeBg=(filePath)->
replaceColor {
image: filePath
colors: {
type: 'rgb'
targetColor: [139, 139, 139]
replaceColor: [0,0,0,0]
}
}, (err, jimpObject)->
if err
return console.log err
jimpObject.write filePath, (err) ->
if err
return console.log err
dir_path="#{__dirname}/../client/static/assets/items/"
fs.readdir dir_path, (err, files)->
files.forEach (file)->
filePath="#{__dirname}/../client/static/assets/items/"+file
removeBg filePath
return
return
request options, (err, response, body)->
soup=new JSSoup(body)
map={}
last=null
ile=0
zal=0
for i in soup.findAll("td")
if (i.text isnt " ") and (i.text.includes "minecraft:")
ile+=1
title=i.text.split("(")[0]
war=0
for j in [0..i.text.length-1]
if i.text[j] is "("
war=j
type=(i.text.substr war+11).split(")")[0]
((type,url)->
file=fs.createWriteStream "#{__dirname}/../client/static/assets/items/#{type}.png"
https.get url,(response)->
console.log type,url
response.pipe(file)
zal+=1
if ile is zal
console.log("Removing gray backgrounds...")
removeBg()
)(type,"https://www.digminecraft.com#{last}")
else if i.find("img") isnt undefined
last=i.find("img").attrs["data-src"]
return