Skip to content

Instantly share code, notes, and snippets.

@itsmeow
Last active July 22, 2021 18:37
Show Gist options
  • Save itsmeow/bb9bca81ffcf736829e1551815b0816e to your computer and use it in GitHub Desktop.
Save itsmeow/bb9bca81ffcf736829e1551815b0816e to your computer and use it in GitHub Desktop.
Lists the largest modpacks that a mod is in
// Run 'npm install [email protected]'
const got = require("got");
const args = process.argv.slice(2).join(" ");
const run = async () => {
let idData = await got
.get(`https://www.modpackindex.com/api/v1/mods?limit=1&name=${args}&page=1`)
.json();
console.log(`Project ${idData.data[0].name} ID ${idData.data[0].id}`);
let result = {
links: {
next: `https://www.modpackindex.com/api/v1/mod/${idData.data[0].id}/modpacks?limit=100&page=1`,
},
};
let data = [];
while (result.links.next !== null) {
result = await got.get(result.links.next).json();
for (let obj of result.data) {
data.push(obj);
}
console.log("Page", result.meta.current_page, "of", result.meta.last_page);
}
let byDownloads = data
.slice(0)
.filter((v, i, s) => i === s.findIndex((v2) => v.slug === v2.slug));
byDownloads.sort((a, b) => a.download_count - b.download_count);
for (let i = 0; i < 50; i++) {
let e = byDownloads[byDownloads.length - i - 1];
console.log(i + 1, e.name, e.download_count, e.slug);
}
};
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment