]> git.plutz.net Git - serve0/commitdiff
simplify progress api
authorpaul <paul@plutz.net>
Fri, 17 Mar 2017 16:30:13 +0000 (16:30 +0000)
committerpaul <paul@plutz.net>
Fri, 17 Mar 2017 16:30:13 +0000 (16:30 +0000)
svn path=/trunk/; revision=182

actions/playctl.sh
pages/playctl.sh

index 6dc138f1561611829149b5991a45e3852d0e9490..9af8f7b8d0c5d9af813ad8eb451feb41aef2721f 100755 (executable)
@@ -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'
index 7ba717b5f29045911afd4395ec1cfb53cfeb2441..36363516a0e2d9422e252fd94ceda8355ef8ec45 100755 (executable)
@@ -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
 }