Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce singleton API client with retry policy #130

Merged
merged 6 commits into from
May 18, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix skip implementation conflict
  • Loading branch information
snobu committed May 18, 2020
commit 8d04caaaba52ce3c0ebad3ae9119dfac28e6befc
15 changes: 14 additions & 1 deletion src/destreamer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@ async function downloadVideo(videoUrls: string[], outputDirectories: string[], s

// let the magic begin...
await new Promise((resolve: any) => {
ffmpegCmd.on('error', (error: any) => {
if (argv.skip && error.message.includes('exists') && error.message.includes(outputPath)) {
pbar.update(video.totalChunks); // set progress bar to 100%
console.log(colors.yellow(`\nFile already exists, skipping: ${outputPath}`));
resolve();
} else {
cleanupFn();

console.log(`\nffmpeg returned an error: ${error.message}`);
process.exit(ERROR_CODE.UNK_FFMPEG_ERROR);
}
});

ffmpegCmd.on('success', () => {
pbar.update(video.totalChunks); // set progress bar to 100%
console.log(colors.green(`\nDownload finished: ${outputPath}`));
Expand All @@ -261,7 +274,7 @@ async function downloadVideo(videoUrls: string[], outputDirectories: string[], s

ffmpegCmd.spawn();
});

process.removeListener('SIGINT', cleanupFn);
}
}
Expand Down