ptgdp: Figure out how many songs we need to grab

This commit is contained in:
Salt 2019-08-14 04:31:57 -05:00
parent 83a32b0090
commit afcb98e06b

20
ptgdp
View File

@ -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"