diff --git a/ptgdp b/ptgdp index 5a9a744..24b8148 100755 --- a/ptgdp +++ b/ptgdp @@ -226,12 +226,26 @@ playlist() { local -i dlexist=0 local -i dlsuccess=0 local -i dlfailure=0 + local -i maxlines=0 while read line; do - [ -z "$line" ] && continue - # Ignore comment lines - if ! [ "${line#\#}" = "$line" ]; then + # Strictly speaking, this removes all whitespace from the line + # While not *exactly* what I'm looking for, it's sufficient for trimming whitespace lines + local linenows=${line//[[:space:]]} + if ! [ "${line#\#}" = "$line" ] || [ -z "$linenows" ]; then continue fi + unset linenows + maxlines+=1 + done < "$1" + log "Enqueued playlist with $maxlines lines" + while read line; do + [ -z "$line" ] && continue + # Ignore comments and blank lines + local linenows=${line//[[:space:]]} + if ! [ "${line#\#}" = "$line" ] || [ -z "$linenows" ]; then + continue + fi + unset linenows rm "$_tmpfile"* > /dev/null 2>&1 # Do the do cachesong "$line"