1
0
mirror of https://github.com/snobu/destreamer.git synced 2026-01-17 05:22:18 +00:00

Merge pull request #12 from angelobpool/patch-1

Added audio/video quality option
This commit is contained in:
Adrian Calinescu
2020-03-22 14:17:23 +02:00
committed by GitHub
2 changed files with 108 additions and 99 deletions

View File

@@ -31,7 +31,6 @@ Destreamer takes a [honeybadger](https://www.youtube.com/watch?v=4r7wHMg5Yjg) ap
## USAGE ## 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) * 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)
* 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 * `npm install` to restore packages* `npm install` to restore packages
* `npm run -s build` to transpile TypeScript to JavaScript * `npm run -s build` to transpile TypeScript to JavaScript
@@ -44,6 +43,9 @@ Options:
--videoUrls [array] [required] --videoUrls [array] [required]
--username [string] [required] --username [string] [required]
--outputDirectory [string] [default: "videos"] --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" \ $ node destreamer.js --username username@example.com --outputDirectory "videos" \
@@ -53,10 +55,8 @@ $ node destreamer.js --username username@example.com --outputDirectory "videos"
``` ```
You can use an absolute path for `--outputDirectory`, for example `/mnt/videos`. You can use an absolute path for `--outputDirectory`, for example `/mnt/videos`.
### To download a list of videos To choose preferred video format and quality you can use the `-f` (`--format`) option. It exposes a native [`youtube-dl` parameter][4].
If you do not pass this parameter then `youtube-dl` will download the best available quality for each video.
~~There's no implementation that does that (yet). There's some work happening to support this, give it some time.~~<br>
See usage above.
## EXPECTED OUTPUT ## EXPECTED OUTPUT
@@ -94,3 +94,6 @@ The video is now saved under `videos/`, or whatever the `outputDirectory` const
## _IT JUST KEEPS CRASHING FOR ME!_ ## _IT JUST KEEPS CRASHING FOR ME!_
Check out this issue if it keeps crashing for you - Check out this issue if it keeps crashing for you -
https://github.com/snobu/destreamer/issues/6 https://github.com/snobu/destreamer/issues/6
[4]: https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection

View File

@@ -13,12 +13,18 @@ const args: string[] = process.argv.slice(2); // TODO: Remove this
const argv = yargs.options({ const argv = yargs.options({
videoUrls: { type: 'array', demandOption: true }, videoUrls: { type: 'array', demandOption: true },
username: { type: 'string', 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; }).argv;
console.info('Video URLs: %s', argv.videoUrls); console.info('Video URLs: %s', argv.videoUrls);
console.info('Username: %s', argv.username); console.info('Username: %s', argv.username);
console.info('Output Directory: %s', argv.outputDirectory); console.info('Output Directory: %s', argv.outputDirectory);
console.info('Video/Audio Quality: %s', argv.format);
function sanityChecks() { function sanityChecks() {
try { try {
@@ -106,7 +112,7 @@ async function rentVideoForLater(videoUrls: string[], username: string, outputDi
console.log('Spawning youtube-dl with cookie and HLS URL...'); console.log('Spawning youtube-dl with cookie and HLS URL...');
const youtubedlCmd = 'youtube-dl --no-call-home --no-warnings ' + 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`); // console.log(`\n\n[DEBUG] Invoking youtube-dl: ${youtubedlCmd}\n\n`);
var result = execSync(youtubedlCmd, { stdio: 'inherit' }); var result = execSync(youtubedlCmd, { stdio: 'inherit' });
} }