ptgdp: More default-search fixes, change sanitization location

This commit is contained in:
Salt 2019-09-13 21:13:48 -05:00
parent e5ad73d4cc
commit ae55cb3ce3

9
ptgdp
View File

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