occivink / mpv-scripts

Various scripts for mpv
The Unlicense
417 stars 38 forks source link

Add youtube downloader and fix encode time argument #71

Open m-braunschweig opened 11 months ago

m-braunschweig commented 11 months ago

This PR includes 2 commits. One adding support for downloading videos from YouTube. The other one fixes a bug in the end timestamp.

This pull request is a rewritten version from #55 that only features the yt-dlp option, is written more clearly and also applies output arguments properly. Like the original PR it should close #32 and close #46.

Please note that this PR still needs some testing with different YouTube link formats.

Commit messages: [encode] Allow downloading YouTube videos

This commit adds functionality to download YouTube videos. It uses a pattern match in case of a stream to ensure the stream is coming from YouTube. This is done to don't disrupt other stream methods.

Furthermore ffmpeg input and output arguments are getting split since we need to differentiate between them, if we pass them to youtube dlp. If we are handling a normal file they just get merged together.

[encode] Fix timespan argument

This replaces the -to argument with a -t. This is done since -to expects a end timestamp and -t expects a time how long the clip should be. Since we compute how long the clip is we want -t instead of -to.

This bug was originally introduced in commit 2769f0475c0b1c6d8251386f3cf1cceaafb78ebe