-
Notifications
You must be signed in to change notification settings - Fork 1
/
meta.js
38 lines (31 loc) · 884 Bytes
/
meta.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
const download = require("download");
var fs = require("fs");
function downloadJson(url, filePath) {
return download(url, filePath).then(() => {});
}
function printProgress(progress, total) {
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(progress + "/" + total);
}
async function main() {
let baseURI = "https://api.chainrunners.xyz/tokens/metadata/";
let projectName = "Runners";
let folderBase = "/extracted";
let projectDir = __dirname + folderBase + "/" + projectName + "/meta/";
let size = 13000;
if (!fs.existsSync(projectDir)) {
fs.mkdirSync(projectDir, { recursive: true });
}
for (var i = 1; i < size; i++) {
let file = baseURI + i;
await downloadJson(file, projectDir);
printProgress(i, size);
}
console.log("Download complete");
}
try {
main();
} catch (error) {
console.error(error);
}