From f63bf2a44d2101a7e1917f7581271e5c2ab0a464 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sun, 22 Sep 2019 21:43:34 -0700 Subject: [PATCH] support for playlists now available --- ytdl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ytdl b/ytdl index 2c28b82..542fb02 100755 --- a/ytdl +++ b/ytdl @@ -1,18 +1,25 @@ #!/bin/sh + dir=`for d in ~/Music/*;do if [ -d "$d" ] then basename "$d" fi done | dmenu -i -l 10 -p 'Pick a directory'` -echo ~/Music/$dir + if [ -z "$dir" ]; then exit; fi +mkdir -p "~/Music/$dir" url=`echo '' | dmenu -p 'Enter a url'` if [ -z "$url" ]; then exit; fi # youtube-dl constantly breaks so --verbose is here for your pleasure -youtube-dl --extract-audio --verbose \ - --audio-format mp3 \ - -o "~/Music/$dir/%(title)s.%(ext)s" \ - "$url" +cmd='youtube-dl --extract-audio --verbose --audio-format mp3' +outplaylist="-o ~/Music/$dir/%(autonumber)02d $url" +outsingle="-o ~/Music/$dir/%(title)s.%(ext)s $url" + +if echo "$url" | grep -q '&list='; then + $cmd $outplaylist +else + $cmd $outsingle +fi