]> git.plutz.net Git - serve0/commitdiff
improved processing of progress bar
authorpaul <paul@plutz.net>
Fri, 17 Mar 2017 15:54:26 +0000 (15:54 +0000)
committerpaul <paul@plutz.net>
Fri, 17 Mar 2017 15:54:26 +0000 (15:54 +0000)
svn path=/trunk/; revision=181

actions/playctl.sh
pages/playctl.sh

index 2934b90fd2b8be4d868451e8df27bcf49691768c..6dc138f1561611829149b5991a45e3852d0e9490 100755 (executable)
@@ -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
index 723d37f8897924b08e1a338f1417f19bd39f7b1f..7ba717b5f29045911afd4395ec1cfb53cfeb2441 100755 (executable)
@@ -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