diff --git a/ptgdp b/ptgdp index d860607..073a61f 100755 --- a/ptgdp +++ b/ptgdp @@ -55,12 +55,14 @@ checkforsong() { [ -z "$1" ] && return 1 # Very rudimentary implementation # TODO: Make this a lot more thorough, maybe ensure MIME is good - for file in "$_ptgdpmusicdir/$1"*; do + sanitize "$1" + for file in "$_ptgdpmusicdir/$_return"*; do if [ -f "$file" ]; then _return="$file" return 0 fi done + unset _return return 1 } cachesong() { @@ -107,10 +109,11 @@ cachesong() { else output="$( youtube-dl \ + --default-search "ytsearch:" \ --get-title \ --geo-bypass \ --playlist-items 1 \ - ytsearch:"$1" 2>&1 + "$1" 2>&1 )" exitcode="$?" if [ $exitcode -gt 0 ]; then @@ -225,7 +228,7 @@ validateplaylistenv() { } sanitize() { [ -z "$1" ] && return 1 # String to strip special chars from - _return="${1//[^ a-zA-Z0-9\[\]|()_-]/}" + _return="${1//[^ a-zA-Z0-9\[\]|()_-:]/}" } # Traps