From a71c2f4849203931aa2437e3ff7d8c200c6f5239 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 4 May 2016 22:54:07 +0000 Subject: [PATCH] time display for files from directory svn path=/trunk/; revision=126 --- actions/watch.sh | 8 +++++++- pages/list.sh | 3 +-- pages/playctl.sh | 22 ++++++++-------------- templates/playctl.html.sh | 2 +- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/actions/watch.sh b/actions/watch.sh index b3463b9..3fae936 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -54,12 +54,18 @@ case "${_COOKIE[watch]}" in [ -n "$location" ] && playuri="${treeroot%/}/${location#/}" [ -n "$info" ] && playuri="${_DATA}/videos/$info" + metafile="${_DATA}/meta/${info}.meta" + + playmeta="${_DATA}/mplayer.meta" fifofile="${_DATA}/mplayer.fifo" statusfile="${_DATA}/mplayer.status" volume="$(validate "$(cat "${_DATA}/mplayer.volume")" '[1-9]?[0-9]|100' 20)" [ \! -p "$fifofile" ] && rm -f "$fifofile" && mkfifo -m 600 "$fifofile" - debug PLAYURI $playuri + debug PLAYURI "$playuri" + + [ -f "$metafile" ] && cp "$metafile" "$playmeta" \ + || "${_EXEC}"/helpers/genmeta.sh "$playuri" "$playmeta" >/dev/null DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 \ nohup /usr/bin/mplayer -ao pulse \ diff --git a/pages/list.sh b/pages/list.sh index 4d25103..284b918 100755 --- a/pages/list.sh +++ b/pages/list.sh @@ -74,8 +74,7 @@ _printVideo(){ linkinfo="$(urlsafe "$info")" htmlinfo="$(htmlsafe "$info")" - [ "$(($length % 60))" -lt 10 ] && minutes="$(($length / 60)):0$(($length % 60))" \ - || minutes="$(($length / 60)):$(($length % 60))" + minutes="$(printf "%d:%02d" $(($length / 60)) $(($length % 60)) )" tee "$cache" < diff --git a/pages/playctl.sh b/pages/playctl.sh index 1150780..e273237 100755 --- a/pages/playctl.sh +++ b/pages/playctl.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014 2016 Paul Hänsch +# Copyright 2014, 2016 Paul Hänsch # # This file is part of Serve0. # @@ -24,19 +24,13 @@ location="$(invalidate "${_GET[l]}" '(.*/)?\.\.(/.*)?|' /)" directory="${location%/*}" statusfile="$_DATA/mplayer.status" -TITLE="$info" - -if [ -n "$info" ]; then - video="${_DATA}/videos/$info" - meta="${_DATA}/meta/$info.meta" - tags="$(sed -n '2p' "$meta")" - description="$(sed -n '3,$p' "$meta")" - head -n1 "$meta" |read length width height x -else - video="${treeroot%/}/${location#/}" - meta=''; tags=''; length=0; width=0; height=0; - description=0 -fi +[ -n "$info" ] && video="${_DATA}/videos/$info" \ + || video="${treeroot%/}/${location#/}" + +meta="${_DATA}/mplayer.meta" +tags="$(sed -n '2p' "$meta")" +description="$(sed -n '3,$p' "$meta")" +head -n1 "$meta" |read length width height TITLE volume=$(validate "$(cat "$_DATA/mplayer.volume")" '[1-9]?[0-9]|100' 20) diff --git a/templates/playctl.html.sh b/templates/playctl.html.sh index 62fe1d2..8a94bd3 100755 --- a/templates/playctl.html.sh +++ b/templates/playctl.html.sh @@ -53,7 +53,7 @@ cat <Progress - $(($length / 60)):$(($length % 60)) min + $(printf "%d:%02d min" $(($length / 60)) $(($length % 60)) ) Width: $width Height: $height
-- 2.39.2