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"
touch "$_musicdir/.symlink"
else
log "Failed to make symlink to music directory"
error "Failed to make symlink to music directory"
log "Music can be found at \"$_musicdir\""
fi
fi
@ -193,6 +193,7 @@ playlist() {
exitcode="$?"
if [ $exitcode -gt 0 ]; then
error "Could not find song \"$line\""
dlerror+=1
continue
fi
if ! [ "$output" = "${output#*WARNING}" ]; then
@ -200,13 +201,14 @@ playlist() {
else
log "$line - \"$output\""
fi
dlsuccess+=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" \
"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
else
elif [ -z "$_optdryrun" ]; then
if [ -z "$_optdownloadonly" ]; then
notify "Finished building queue" \
"The playlist queue has been built in Audacious"
@ -216,6 +218,8 @@ playlist() {
"Your songs have been cached and are ready for offline playback"
log "Finished downloading: $dlexist cached, $dlsuccess downloaded, $dlfailure failed"
fi
else
log "Finished dry run: $dlsuccess succeeded, $dlfailure failed"
fi
}