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