Created
October 18, 2022 03:06
-
-
Save rbk/ed50b2bcab9fc6b6ca50b2ab1f23c52e to your computer and use it in GitHub Desktop.
Download a file with node
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 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