Skip to content

Instantly share code, notes, and snippets.

@rbk
Created October 18, 2022 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbk/ed50b2bcab9fc6b6ca50b2ab1f23c52e to your computer and use it in GitHub Desktop.
Save rbk/ed50b2bcab9fc6b6ca50b2ab1f23c52e to your computer and use it in GitHub Desktop.
Download a file with node
const files = [
"https://archive.org/download/OTRR_Gunsmoke_Singles/Gunsmoke%2052-04-26%20%28001%29%20Billy%20the%20Kid.mp3"
]
const exec = require('child_process').exec;
const downloadFile = (url) => {
return new Promise((resolve) => {
console.log(`wget ${url} --no-check-certificate`)
exec(`wget ${url} --no-check-certificate`, function(err, stdout, stderr) {
if (err) {
console.log('ERR', err, url)
} else {
console.log('SUCCESS ' + url);
resolve(1)
}
});
})
}
(async () => {
await Promise.all(files.map(url => downloadFile(url)))
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment