youtube-par-cmd: fall back to playlist id if playlist title is weird

This commit is contained in:
gutmet 2020-10-14 07:39:49 +02:00
parent b5542893b4
commit ceeb17d78b

View File

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