youtube: unify parallel downloads of pure audio and video

* also: dump titles in playlist order as txt
This commit is contained in:
gutmet 2020-10-13 22:31:08 +02:00
parent a92593a740
commit b5e168b0fe
3 changed files with 14 additions and 10 deletions

View File

@ -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"

12
youtube-par-cmd Executable file
View File

@ -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"

View File

@ -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"