From 1be65d11fc6ac0693f72ca442fcc4ccb24fd746a Mon Sep 17 00:00:00 2001
From: paul <paul@plutz.net>
Date: Fri, 29 Apr 2016 12:53:09 +0000
Subject: [PATCH] fix status bar, correct reading of mplayer output

svn path=/trunk/; revision=123
---
 pages/playctl.sh          | 7 +++++--
 templates/playctl.html.sh | 3 ---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/pages/playctl.sh b/pages/playctl.sh
index c5d6c09..c4ece2c 100755
--- a/pages/playctl.sh
+++ b/pages/playctl.sh
@@ -45,9 +45,12 @@ debug VIDEO: $video
 progress(){
   tail --pid=$$ -f "$statusfile" \
   | tr '\r' '\n' \
-  | sed -urn 's;^.* ([0-9]{1,3})(,[0-9]+)?% *$;\1;p' \
+  | sed -urn '1~5s;^.* V: +([0-9]+)(\.[0-9]+) A-V:.*$;\1;p' \
+  | while read m; do
+    printf "%s\n" "$(($m * 100 / $length))"
+  done \
   | while read n; do
-    [ "$n" != "$previous" ] && printf "%s\n" "$((100 - $n))"
+    [ "$n" != "$previous" ] && printf "%s\n" "$n"
     previous=$n
   done
 }
diff --git a/templates/playctl.html.sh b/templates/playctl.html.sh
index 1725f7f..6f435e7 100755
--- a/templates/playctl.html.sh
+++ b/templates/playctl.html.sh
@@ -107,7 +107,4 @@ progress \
   printf '<span class="progress"><span style="width: %s%%;">%s</span></span>\n' $n $n
 done
 
-
-
-
 # vi:set filetype=html:
-- 
2.39.5