diff options
Diffstat (limited to 'src/download-playlist.js')
-rwxr-xr-x | src/download-playlist.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/download-playlist.js b/src/download-playlist.js index 18e1a7f..0b5ea58 100755 --- a/src/download-playlist.js +++ b/src/download-playlist.js @@ -102,17 +102,15 @@ async function downloadCrawl(topPlaylist, initialOutPath = './out/') { return recursive(topPlaylist.items, initialOutPath) } -async function main() { +async function main(args) { // TODO: Implement command line stuff here - if (process.argv.length === 2) { + if (args.length === 0) { console.error('Usage: download-playlist <playlistFile> [opts]') return } - const playlist = updatePlaylistFormat( - JSON.parse(await readFile(process.argv[2])) - ) + const playlist = updatePlaylistFormat(JSON.parse(await readFile(args[0]))) const outPlaylist = await downloadCrawl(playlist) @@ -122,5 +120,7 @@ async function main() { process.exit(0) } -main() - .catch(err => console.error(err)) +if (require.main === module) { + main(process.argv.slice(2)) + .catch(err => console.error(err)) +} |