diff --git a/youtube-par-cmd b/youtube-par-cmd index e29e5fc..2236114 100755 --- a/youtube-par-cmd +++ b/youtube-par-cmd @@ -8,14 +8,21 @@ playlistURL="$2" playlistJSON=`youtube-dl "$playlistURL" --flat-playlist -J` playlistTitle=`echo "$playlistJSON" | jq -r '.title'` -mkdir "$playlistTitle" + +output="$(mkdir "$playlistTitle")" +status=$? +if [ $status -ne 0 ]; then + playlistTitle=`echo "$playlistJSON" | jq -r '.id'` + mkdir "$playlistTitle" +fi + 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" +m3uFile="Playlist - $playlistTitle"".m3u" +echo "#EXTM3U" > "$m3uFile" echo "$urls" | while read url; do - find . -name "*$url*" -prune >> "$M3Ufile" + find . -name "*$url*" -prune >> "$m3uFile" done