From b5e168b0fe02d100d285fa23f1c5f06d5163f6c2 Mon Sep 17 00:00:00 2001 From: gutmet Date: Tue, 13 Oct 2020 22:31:08 +0200 Subject: [PATCH] youtube: unify parallel downloads of pure audio and video * also: dump titles in playlist order as txt --- youtube-audio-par-dl | 6 +----- youtube-par-cmd | 12 ++++++++++++ youtube-par-dl | 6 +----- 3 files changed, 14 insertions(+), 10 deletions(-) create mode 100755 youtube-par-cmd diff --git a/youtube-audio-par-dl b/youtube-audio-par-dl index d2b2635..7f4ffd6 100755 --- a/youtube-audio-par-dl +++ b/youtube-audio-par-dl @@ -1,7 +1,3 @@ #!/usr/bin/env bash -# only works with new versions of youtube-dl that don't shuffle the json dump! - -# pass url of youtube playlist as argument and download in parallel - -youtube-dl "$1" --flat-playlist -j | awk '{print $2}' | tr -d ',"' | awk '{print "https://www.youtube.com/watch?v=" $0}' | xargs -n 1 -P 10 youtube-audio-dl +youtube-par-cmd "youtube-audio-dl" "$1" diff --git a/youtube-par-cmd b/youtube-par-cmd new file mode 100755 index 0000000..92c3e0b --- /dev/null +++ b/youtube-par-cmd @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# called from youtube-audio-par-dl and youtube-par-dl with corresponding download command +# only works with jq (command line JSON processor) + +cmd="$1" +playlistURL="$2" + +playlistJSON=`youtube-dl "$playlistURL" --flat-playlist -J` +playlistTitle=`echo "$playlistJSON" | jq -r '.title'` +echo "$playlistJSON" | jq -r '.entries[].title' >> "Playlist - $playlistTitle"".txt" +echo "$playlistJSON" | jq -r '.entries[].url' | awk '{print "https://www.youtube.com/watch?v=" $0}' | xargs -n 1 -P 10 "$cmd" diff --git a/youtube-par-dl b/youtube-par-dl index 070a0f3..5d35fee 100755 --- a/youtube-par-dl +++ b/youtube-par-dl @@ -1,7 +1,3 @@ #!/usr/bin/env bash -# only works with new versions of youtube-dl that don't shuffle the json dump! - -# pass url of youtube playlist as argument and download in parallel - -youtube-dl "$1" --flat-playlist -j | awk '{print $2}' | tr -d ',"' | awk '{print "https://www.youtube.com/watch?v=" $0}' | xargs -n 1 -P 10 youtube-dl +youtube-par-cmd "youtube-dl" "$1"