From ccfecec1a0f29212e4053ff637c4f2c0490ac40d Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 8 May 2016 21:15:24 +0000 Subject: [PATCH] discard previous status lines when feeding progrss bar svn path=/trunk/; revision=129 --- pages/playctl.sh | 7 +++++-- templates/playctl.html.sh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pages/playctl.sh b/pages/playctl.sh index e273237..c01b800 100755 --- a/pages/playctl.sh +++ b/pages/playctl.sh @@ -37,11 +37,14 @@ volume=$(validate "$(cat "$_DATA/mplayer.volume")" '[1-9]?[0-9]|100' 20) debug VIDEO: $video progress(){ + discard="$(tail -n2 "$statusfile" |sed 's;[^\r];;g' |wc -c)" + tail --pid=$$ -f "$statusfile" \ | tr '\r' '\n' \ - | sed -urn '1~5s;^.* V: +([0-9]+)(\.[0-9]+) A-V:.*$;\1;p' \ + | tail -n+$discard \ + | sed -urn '1~10s;^.* V: +([0-9]+)(\.[0-9]+) A-V:.*$;\1;p' \ | while read m; do - printf "%d %d:%02d\n" "$(($m * 100 / $length))" "$(($m / 60))" "$(($m % 60))" + printf "%d %d\n" "$(($m * 100 / $length))" "$m" done \ | while read n; do [ "$n" != "$previous" ] && printf "%s\n" "$n" diff --git a/templates/playctl.html.sh b/templates/playctl.html.sh index 8a94bd3..e361dda 100755 --- a/templates/playctl.html.sh +++ b/templates/playctl.html.sh @@ -104,7 +104,7 @@ EOF cnt=0 progress \ | while read p t; do - printf '%s\n' "${p}" "${t}" + printf '%d:%02d\n' "${p}" "$(($t / 60))" "$(($t % 60))" done # vi:set filetype=html: -- 2.39.2