-
Notifications
You must be signed in to change notification settings - Fork 0
/
picGet.js
40 lines (37 loc) · 1.3 KB
/
picGet.js
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
const login = require("./resources/login"),
{
aesDecrypt,
aesEncrypt
} = require("./resources/aes"),
request = require("request"),
fs = require("fs");
let config,
fileId=process.argv[2]?process.argv[2]:"1e5f725818f8429b81ef8edc1e5a516c",
name="📖Physics运动的描述";
//文件id i.g: 42ba6a192067477ab1546736ff1a3caf
login().then((res) => {
config=res;
request({
url: `http://note.func.zykj.org/api/Resources/GetByFileId?${aesEncrypt("fileId="+fileId)}`,
method: "GET",
json: true,
headers: {
"content-type": "application/json",
"Authorization": `Bearer ${config.token}`
}
}, (err, res, data) => {
if(fs.existsSync(`picDownload/${name}`)){
console.warn("已存在文件夹,请删除后重试");
return;
}
fs.mkdirSync(`picDownload/${name}`);
var a=aesDecrypt(data.data).match(/cloudnote\/notes\/sxz[^\"]*?.jpg/g);
for(var i in a)
download("http://friday-note.oss-cn-hangzhou.aliyuncs.com/"+a[i],i+".jpg");
})
})
async function download(address, title) {
var req = request.get(address,null);
var ws = fs.createWriteStream(`picDownload/${name}/${title}`);
req.pipe(ws);
}