mirror of
https://github.com/snobu/destreamer.git
synced 2026-01-16 21:12:13 +00:00
Add noCleanup argument (#95)
* Added noCleanup argument (don't delete temp audio/video files on ffmpeg error) * Added argument to README Co-authored-by: Aleksa Savic <savicaleksa83@gmail.com>
This commit is contained in:
@@ -78,6 +78,8 @@ Options:
|
|||||||
--verbose, -v Print additional information to the console (use this
|
--verbose, -v Print additional information to the console (use this
|
||||||
before opening an issue on GitHub)
|
before opening an issue on GitHub)
|
||||||
[boolean] [default: false]
|
[boolean] [default: false]
|
||||||
|
--noCleanup, --nc Don't delete the downloaded video file when an FFmpeg
|
||||||
|
error occurs [boolean] [default: false]
|
||||||
```
|
```
|
||||||
|
|
||||||
Download a video -
|
Download a video -
|
||||||
|
|||||||
@@ -54,6 +54,13 @@ export const argv = yargs.options({
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
demandOption: false
|
demandOption: false
|
||||||
|
},
|
||||||
|
noCleanup: {
|
||||||
|
alias: 'nc',
|
||||||
|
describe: `Don't delete the downloaded video file when an FFmpeg error occurs`,
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
demandOption: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -195,6 +195,9 @@ async function downloadVideo(videoUrls: string[], outputDirectories: string[], s
|
|||||||
const cleanupFn = function () {
|
const cleanupFn = function () {
|
||||||
pbar.stop();
|
pbar.stop();
|
||||||
|
|
||||||
|
if (argv.noCleanup)
|
||||||
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(outputPath);
|
fs.unlinkSync(outputPath);
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
@@ -223,11 +226,7 @@ async function downloadVideo(videoUrls: string[], outputDirectories: string[], s
|
|||||||
});
|
});
|
||||||
|
|
||||||
ffmpegCmd.on('error', (error: any) => {
|
ffmpegCmd.on('error', (error: any) => {
|
||||||
pbar.stop();
|
cleanupFn();
|
||||||
|
|
||||||
try {
|
|
||||||
fs.unlinkSync(outputPath);
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
console.log(`\nffmpeg returned an error: ${error.message}`);
|
console.log(`\nffmpeg returned an error: ${error.message}`);
|
||||||
process.exit(ERROR_CODE.UNK_FFMPEG_ERROR);
|
process.exit(ERROR_CODE.UNK_FFMPEG_ERROR);
|
||||||
|
|||||||
Reference in New Issue
Block a user