ptgdp: Revise logging a bit more, add statistics at end of dry run

This commit is contained in:
Salt 2019-07-28 17:50:23 -05:00
parent d699c8195f
commit 300422f1a4

10
ptgdp
View File

@ -139,7 +139,7 @@ playlist() {
log "Made symlink to music directory" log "Made symlink to music directory"
touch "$_musicdir/.symlink" touch "$_musicdir/.symlink"
else else
log "Failed to make symlink to music directory" error "Failed to make symlink to music directory"
log "Music can be found at \"$_musicdir\"" log "Music can be found at \"$_musicdir\""
fi fi
fi fi
@ -193,6 +193,7 @@ playlist() {
exitcode="$?" exitcode="$?"
if [ $exitcode -gt 0 ]; then if [ $exitcode -gt 0 ]; then
error "Could not find song \"$line\"" error "Could not find song \"$line\""
dlerror+=1
continue continue
fi fi
if ! [ "$output" = "${output#*WARNING}" ]; then if ! [ "$output" = "${output#*WARNING}" ]; then
@ -200,13 +201,14 @@ playlist() {
else else
log "$line - \"$output\"" log "$line - \"$output\""
fi fi
dlsuccess+=1
fi fi
done < <(if [ -n "$_optshuffle" ]; then shuf "$1"; else cat "$1"; fi) done < <(if [ -n "$_optshuffle" ]; then shuf "$1"; else cat "$1"; fi)
if [ "$dlexist" = "0" ] && [ "$dlsuccess" = "0" ]; then if [ "$dlexist" = "0" ] && [ "$dlsuccess" = "0" ] && [ -z "$_optdryrun" ]; then
notify "Failed to enqueue playlist" \ notify "Failed to enqueue playlist" \
"The playlist could not be enqueued. Ensure that youtube-dl is up to date, you have a valid internet connection, and your search queries pull up results" \ "The playlist could not be enqueued. Ensure that youtube-dl is up to date, you have a valid internet connection, and your search queries pull up results" \
normal dialog-error 10000 normal dialog-error 10000
else elif [ -z "$_optdryrun" ]; then
if [ -z "$_optdownloadonly" ]; then if [ -z "$_optdownloadonly" ]; then
notify "Finished building queue" \ notify "Finished building queue" \
"The playlist queue has been built in Audacious" "The playlist queue has been built in Audacious"
@ -216,6 +218,8 @@ playlist() {
"Your songs have been cached and are ready for offline playback" "Your songs have been cached and are ready for offline playback"
log "Finished downloading: $dlexist cached, $dlsuccess downloaded, $dlfailure failed" log "Finished downloading: $dlexist cached, $dlsuccess downloaded, $dlfailure failed"
fi fi
else
log "Finished dry run: $dlsuccess succeeded, $dlfailure failed"
fi fi
} }