Skip to content

Instantly share code, notes, and snippets.

@robertdigital
Forked from zamnuts/yt-dlp-all
Created May 27, 2022 08:40
Show Gist options
  • Select an option

  • Save robertdigital/dff89dee1aa170e985b7d44c67fe4aad to your computer and use it in GitHub Desktop.

Select an option

Save robertdigital/dff89dee1aa170e985b7d44c67fe4aad to your computer and use it in GitHub Desktop.

Revisions

  1. @zamnuts zamnuts created this gist Nov 27, 2021.
    33 changes: 33 additions & 0 deletions yt-dlp-all
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #!/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' \
    '{}';