2020-10-13 22:31:08 +02:00
|
|
|
#!/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'`
|
2020-10-14 07:50:01 +02:00
|
|
|
playlistInfo="$playlistTitle"
|
2020-10-14 07:39:49 +02:00
|
|
|
|
|
|
|
output="$(mkdir "$playlistTitle")"
|
|
|
|
status=$?
|
|
|
|
if [ $status -ne 0 ]; then
|
|
|
|
playlistTitle=`echo "$playlistJSON" | jq -r '.id'`
|
|
|
|
mkdir "$playlistTitle"
|
|
|
|
fi
|
|
|
|
|
2020-10-14 00:05:06 +02:00
|
|
|
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"
|
|
|
|
|
2020-10-14 08:10:30 +02:00
|
|
|
m3uFile="Playlist - $playlistTitle"".m3u8"
|
2020-10-14 07:39:49 +02:00
|
|
|
echo "#EXTM3U" > "$m3uFile"
|
2020-10-14 07:50:01 +02:00
|
|
|
echo "#PLAYLIST:$playlistInfo" >> "$m3uFile"
|
2020-10-14 00:05:06 +02:00
|
|
|
echo "$urls" | while read url; do
|
2020-10-14 07:39:49 +02:00
|
|
|
find . -name "*$url*" -prune >> "$m3uFile"
|
2020-10-14 00:05:06 +02:00
|
|
|
done
|