From: paul Date: Fri, 17 Mar 2017 15:54:26 +0000 (+0000) Subject: improved processing of progress bar X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=e5267e1298f4ffec140c5b3ef43be36079e63c3f;p=serve0 improved processing of progress bar svn path=/trunk/; revision=181 --- 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