From ccc171237dc4fa512e728ef488f15a6f6e99c31c Mon Sep 17 00:00:00 2001 From: Angelo B <43997819+angelobpool@users.noreply.github.com> Date: Sat, 21 Mar 2020 17:10:33 +0100 Subject: [PATCH 1/2] Added audio/video quality option Exposed native youtube-dl option "--format", that gives the ability to choose audio/video format and quality. --- destreamer.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/destreamer.ts b/destreamer.ts index 753fd05..31ff402 100644 --- a/destreamer.ts +++ b/destreamer.ts @@ -13,12 +13,18 @@ const args: string[] = process.argv.slice(2); // TODO: Remove this const argv = yargs.options({ videoUrls: { type: 'array', demandOption: true }, username: { type: 'string', demandOption: true }, - outputDirectory: { type: 'string', default: 'videos' } + outputDirectory: { type: 'string', default: 'videos' }, + format: {alias:"f", + describe: 'Expose youtube-dl --format option, for details see\n https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection', + type:'string', + default:'best' + } }).argv; console.info('Video URLs: %s', argv.videoUrls); console.info('Username: %s', argv.username); console.info('Output Directory: %s', argv.outputDirectory); +console.info('Video/Audio Quality: %s', argv.format); function sanityChecks() { try { @@ -103,7 +109,7 @@ async function rentVideoForLater(videoUrls: string[], username: string, outputDi console.log('Spawning youtube-dl with cookie and HLS URL...'); const youtubedlCmd = 'youtube-dl --no-call-home --no-warnings ' + - `--output "${outputDirectory}/${title}.mp4" --add-header Cookie:"${cookie}" "${hlsUrl}"`; + `-f "${argv.format}" --output "${outputDirectory}/${title}.mp4" --add-header Cookie:"${cookie}" "${hlsUrl}"`; // console.log(`\n\n[DEBUG] Invoking youtube-dl: ${youtubedlCmd}\n\n`); var result = execSync(youtubedlCmd, { stdio: 'inherit' }); } @@ -145,4 +151,4 @@ if (args[0] === 'test') else { sanityChecks(); rentVideoForLater(argv.videoUrls as string[], argv.username, argv.outputDirectory); -} \ No newline at end of file +} From 9f45fc6d370e279b8e4938f42f203e46755a79d3 Mon Sep 17 00:00:00 2001 From: Angelo B <43997819+angelobpool@users.noreply.github.com> Date: Sun, 22 Mar 2020 12:27:33 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7af3929..8bd9692 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ Destreamer takes a [honeybadger](https://www.youtube.com/watch?v=4r7wHMg5Yjg) ap ## USAGE * Edit `destreamer.ts` and replace the username const with your own, you may still need to enter your password or go through 2FA if you don't have the STS cookie saved in Chrome. If you do (i.e. you usually log in to Microsoft Stream with Chrome), then you may try turning `headless: false` to `true` for a truly headless experience) +* To choose preferred video format and quality you can use the "--format" option, it doesn't add anyting new, it only expose a native youtube-dl option, you can find details about accepted parameters on official youtube-dl README here ===> [FORMAT SELECTION](https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection) +If you do not pass any option it will download the best available quality by default. ======= * Edit `destreamer.ts` (`.js` if using the vanilla JS master branch) and replace the username const with your own, you may still need to enter your password or go through 2FA if you don't have the STS cookie saved in Chrome. If you do (i.e. you usually log in to Microsoft Stream with Chrome), then you may try turning `headless: false` to `true` for a truly headless experience) * `npm install` to restore packages* `npm install` to restore packages @@ -45,6 +47,9 @@ Options: --videoUrls [array] [required] --username [string] [required] --outputDirectory [string] [default: "videos"] + --format, -f Expose youtube-dl --format option, for details see + https://github.com/ytdl-org/youtube-dl/blob/master/README.m + d#format-selection [string] [default: "best"] $ node destreamer.js --username username@example.com --outputDirectory "videos" \