#!/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'` mkdir "$playlistTitle" cd "$playlistTitle" urls=`echo "$playlistJSON" | jq -r '.entries[].url'` echo "$urls" | awk '{print "https://www.youtube.com/watch?v=" $0}' | xargs -n 1 -P 10 "$cmd" M3Ufile="Playlist - $playlistTitle"".m3u" echo "#EXTM3U" > "$M3Ufile" echo "$urls" | while read url; do find . -name "*$url*" -prune >> "$M3Ufile" done