Created
November 27, 2021 06:54
-
-
Save zamnuts/c53ba6225164bd5d482945ca7f27a498 to your computer and use it in GitHub Desktop.
yt-dlp playlist concurrent downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
playlistUrl="$1"; | |
numParallelDownloads="${2:-5}"; | |
numParallelFragments="${3:-5}"; | |
[[ -z "$playlistUrl" ]] && echo 'i need a url to a yt playlist please.' >&2 && exit 1; | |
[[ "$numParallelDownloads" =~ '^[^0-9]+$' ]] && echo "expected parameter 2 to be the number of parallel downloads, got '$numParallelDownloads'." >&2 && exit 1; | |
[[ "$numParallelFragments" =~ '^[^0-9]+$' ]] && echo "expected parameter 3 to be the number of parallel fragments, got '$numParallelFragments'." >&2 && exit 1; | |
echo "Reading playlist, this could take a while depending on the number of items..."; | |
echo "URL: $playlistUrl"; | |
echo "Num Parallel Downloads: $numParallelDownloads"; | |
echo "Num Parallel Fragments: $numParallelFragments"; | |
echo ; | |
yt-dlp \ | |
--yes-playlist \ | |
--skip-download \ | |
--quiet \ | |
--print '%(id)s' \ | |
"$playlistUrl" \ | |
| xargs \ | |
-I '{}' \ | |
-P "$numParallelDownloads" \ | |
yt-dlp \ | |
--newline \ | |
--embed-metadata \ | |
--write-subs \ | |
--convert-subs srt \ | |
--concurrent-fragments "$numParallelFragments" \ | |
--format 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b' \ | |
'{}'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment