aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-01-15 21:00:32 +0100
committer0neGal <mail@0negal.com>2023-01-15 21:00:32 +0100
commit7feba3c9eaf52293f8d7c496c6eab5af2168c7c0 (patch)
treeb675155c55ef82163527890fe22e407caf2476bd
parent84a88c8bdbe2f85e14032f5b9941549fb8553f4c (diff)
downloadViper-7feba3c9eaf52293f8d7c496c6eab5af2168c7c0.tar.gz
Viper-7feba3c9eaf52293f8d7c496c6eab5af2168c7c0.zip
added scripts/download_count.js
-rw-r--r--scripts/download_count.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/download_count.js b/scripts/download_count.js
new file mode 100644
index 0000000..dc8fe32
--- /dev/null
+++ b/scripts/download_count.js
@@ -0,0 +1,52 @@
+const https = require("https");
+
+let link = "/repos/0neGal/viper/releases";
+
+let count = 0;
+
+let parse_release = (release) => {
+ let assets = release.assets;
+ for (let i = 0; i < assets.length; i++) {
+ // dont count blockmaps
+ if (assets[i].name.match("blockmap")) {
+ continue;
+ }
+
+ switch(assets[i].name) {
+ // dont count these files
+ case "latest.yml":
+ case "latest-linux.yml":
+ continue;
+ default:
+ count += assets[i].download_count;
+ }
+ }
+}
+
+let parse_json = (json) => {
+ json = JSON.parse(json);
+ for (let i = 0; i < json.length; i++) {
+ parse_release(json[i]);
+ }
+
+ console.log("Download count:", count);
+}
+
+https.get({
+ host: "api.github.com",
+ port: 443,
+ path: link,
+ method: "GET",
+ headers: { "User-Agent": "viper" }
+}, (res) => {
+ res.setEncoding("utf8");
+ let res_data = "";
+
+ res.on("data", data => {
+ res_data += data;
+ });
+
+ res.on("end", () => {
+ parse_json(res_data);
+ });
+})