From e2388ebb332a514f070ec5a668f23b08dda83546 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 17 Mar 2017 16:30:13 +0000 Subject: [PATCH] simplify progress api svn path=/trunk/; revision=182 --- actions/playctl.sh | 6 +----- pages/playctl.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 11 deletions(-) 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 } -- 2.39.2