From: paul Date: Sun, 8 May 2016 21:15:24 +0000 (+0000) Subject: discard previous status lines when feeding progrss bar X-Git-Url: http://git.plutz.net/?p=serve0;a=commitdiff_plain;h=ccfecec1a0f29212e4053ff637c4f2c0490ac40d discard previous status lines when feeding progrss bar svn path=/trunk/; revision=129 --- 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: