From: paul Date: Fri, 17 Mar 2017 16:30:13 +0000 (+0000) Subject: simplify progress api X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=e2388ebb332a514f070ec5a668f23b08dda83546;p=serve0 simplify progress api svn path=/trunk/; revision=182 --- diff --git a/actions/playctl.sh b/actions/playctl.sh index 6dc138f..9af8f7b 100755 --- a/actions/playctl.sh +++ b/actions/playctl.sh @@ -36,11 +36,7 @@ if [ "${_GET[api]}" = progress ]; then [ "$line" = "BREAK" ] && exit 0 printf '%s\n' "$line" 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:--1}))" "$m" - previous="$m" - done + | sed -urn '1~12s;^.* V: *+([0-9]+)(\.[0-9]+) A-V:.*$;\1;p' exit 0 elif [ "${_GET[api]}" = volume ]; then printf 'Content-Type: text/plain\r\n\r\n' diff --git a/pages/playctl.sh b/pages/playctl.sh index 7ba717b..3636351 100755 --- a/pages/playctl.sh +++ b/pages/playctl.sh @@ -83,10 +83,10 @@ progress(){ [ "$line" = "BREAK" ] && exit 0 printf '%s\n' "$line" 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:--1}))" "$m" - previous="$m" - done - fi + | sed -urn '1~12s;^.* V: *+([0-9]+)(\.[0-9]+) A-V:.*$;\1;p' + fi \ + | while read m; do + [ "$m" != "$previous" ] && printf "%d %d\n" "$(($m * 100 / ${length:--1}))" "$m" + previous="$m" + done }