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
|
(async () => {
const fs = require('fs');
const axios = require('axios');
const child_process = require('child_process');
if (fs.existsSync("./output")) fs.rmSync("./output", { recursive: true });
fs.mkdirSync("./output");
let output = {};
let total = 0;
console.log("Fetching server...");
const songs = (await axios.get("https://argon.minteck.org/api/get_list.php")).data.songs;
console.log("Processing songs...");
for (let id of Object.keys(songs)) {
if (!id.startsWith(":")) {
const song = songs[id];
console.log(id + " (" + song.author + " - " + song.name + ")")
let o = {
_total: -1,
local: song._localViews,
youtube: null,
soundcloud: null
}
if (song.external.youtube) {
let dl = JSON.parse(child_process.execFileSync("yt-dlp", ["-j", "https://youtu.be/" + song.external.youtube]).toString());
console.log(" " + dl.view_count + " view(s) on YouTube");
o.youtube = dl.view_count;
} else {
console.log(" Song is not on YouTube");
}
if (song.external.soundcloud) {
let dl = JSON.parse(child_process.execFileSync("yt-dlp", ["-j", "https://soundcloud.com/" + song.external.soundcloud]).toString());
console.log(" " + dl.view_count + " view(s) on SoundCloud");
o.soundcloud = dl.view_count;
} else {
console.log(" Song is not on SoundCloud");
}
o._total = o.local + o.youtube + o.soundcloud
total += o._total;
output[id] = o;
}
}
fs.writeFileSync("./output/data.json", JSON.stringify(output, null, 2));
fs.writeFileSync("./output/total.json", JSON.stringify(total, null, 2));
})()
|