diff options
author | liam4 <towerofnix@gmail.com> | 2017-07-21 22:27:34 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-07-21 22:27:34 -0300 |
commit | b6e90e8f380569803b9a83f8997159b34d64e501 (patch) | |
tree | b2ac9c18415301e90dc9980255ea48e54a87b9f7 /src/download-playlist.js | |
parent | 13ec7f5c5408c787e8e424a79ffeea281b044b6f (diff) |
Make some error handling for YouTube downloads
Diffstat (limited to 'src/download-playlist.js')
-rwxr-xr-x | src/download-playlist.js | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/src/download-playlist.js b/src/download-playlist.js index 87d60c3..390d241 100755 --- a/src/download-playlist.js +++ b/src/download-playlist.js @@ -88,34 +88,43 @@ async function downloadCrawl(topPlaylist, initialOutPath = './out/') { ` => ${targetFile}\x1b[0m` ) - const downloader = makePowerfulDownloader( - getDownloaderFor(item.downloaderArg) - ) + // Woo-hoo, using block labels for their intended purpose! (Maybe?) + downloadProcess: { + const downloader = makePowerfulDownloader( + getDownloaderFor(item.downloaderArg) + ) - const outputtedFile = await downloader(item.downloaderArg) + const outputtedFile = await downloader(item.downloaderArg) - let ffmpegSuccess = false + // If the return of the downloader is false, then the download + // failed. + if (outputtedFile === false) { + console.error( + `\x1b[33;1mDownload failed (item skipped): ${item.name}\x1b[0m` + ) - try { - await promisifyProcess(spawn('ffmpeg', [ - '-i', outputtedFile, + break downloadProcess + } - // A bug (in ffmpeg or macOS; not this) makes it necessary to have - // these options on macOS, otherwise the outputted file length is - // wrong. - '-write_xing', '0', + try { + await promisifyProcess(spawn('ffmpeg', [ + '-i', outputtedFile, - targetFile - ]), false) + // A bug (in ffmpeg or macOS; not this) makes it necessary to have + // these options on macOS, otherwise the outputted file length is + // wrong. + '-write_xing', '0', - ffmpegSuccess = true - } catch(err) { - console.error( - `\x1b[33;1mFFmpeg failed (item skipped): ${item.name}\x1b[0m` - ) - } + targetFile + ]), false) + } catch(err) { + console.error( + `\x1b[33;1mFFmpeg failed (item skipped): ${item.name}\x1b[0m` + ) + + break downloadProcess + } - if (ffmpegSuccess) { console.log('Added:', item.name) outPlaylist.push({name: item.name, downloaderArg: targetFile}) } |