Last active
November 24, 2022 18:06
-
-
Save filiptronicek/fdfc009371401b9d63716759a90887f4 to your computer and use it in GitHub Desktop.
open-vsx.org extension hoarder - a script for downloading a lot of extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs/promises"); | |
const execSync = require("child_process").execSync; | |
const toDownload = 100; | |
const downloadFolder = "downloaded"; | |
const getExtensions = async () => { | |
const openVsxResponse = await fetch( | |
`https://open-vsx.org/api/-/search?size=${toDownload}&sortBy=downloadCount&sortOrder=desc` | |
); | |
const openVsxData = await openVsxResponse.json(); | |
const downloadLinks = openVsxData.extensions.map((ext) => ext.files.download); | |
const downloadFolderExists = await fs | |
.access(downloadFolder) | |
.then(() => true) | |
.catch(() => false); | |
if (!downloadFolderExists) { | |
await fs.mkdir(downloadFolder); | |
} | |
downloadLinks.forEach((link) => { | |
const fileExists = require("fs").existsSync(fileOutputLocation); | |
if (fileExists) { | |
console.info("Skipping") | |
return; | |
} | |
execSync(`curl -L ${link} -o ${fileOutputLocation}`); | |
console.info(`Downloaded ${link}`); | |
}); | |
}; | |
getExtensions(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment