From e5267e1298f4ffec140c5b3ef43be36079e63c3f Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 17 Mar 2017 15:54:26 +0000 Subject: [PATCH] improved processing of progress bar svn path=/trunk/; revision=181 --- actions/playctl.sh | 3 ++- pages/playctl.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/actions/playctl.sh b/actions/playctl.sh index 2934b90..6dc138f 100755 --- a/actions/playctl.sh +++ b/actions/playctl.sh @@ -30,6 +30,7 @@ if [ "${_GET[api]}" = progress ]; then cr="$(printf \\r)" printf 'Content-Type: text/plain\r\n\r\n' + read length <${_DATA}/mplayer.meta tail --pid=$$ -c100 -f "$statusfile" \ | while read -d "$cr" line; do [ "$line" = "BREAK" ] && exit 0 @@ -37,7 +38,7 @@ if [ "${_GET[api]}" = progress ]; then done \ | sed -urn '1~12s;^.* V: *+([0-9]+)(\.[0-9]+) A-V:.*$;\1;p' \ | while read m; do - [ "$m" != "$previous" ] && printf "%d %d\n" "$(($m * 100 / $length))" "$m" + [ "$m" != "$previous" ] && printf "%d %d\n" "$(($m * 100 / ${length:--1}))" "$m" previous="$m" done exit 0 diff --git a/pages/playctl.sh b/pages/playctl.sh index 723d37f..7ba717b 100755 --- a/pages/playctl.sh +++ b/pages/playctl.sh @@ -85,7 +85,7 @@ progress(){ done \ | sed -urn '1~12s;^.* V: *+([0-9]+)(\.[0-9]+) A-V:.*$;\1;p' \ | while read m; do - [ "$m" != "$previous" ] && printf "%d %d\n" "$(($m * 100 / $length))" "$m" + [ "$m" != "$previous" ] && printf "%d %d\n" "$(($m * 100 / ${length:--1}))" "$m" previous="$m" done fi -- 2.39.2