X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=pages%2Fview.sh;h=fef4f780a8066c5d203df769748b4aead5cc8bf5;hb=699ce04d08d429ef5a7dbda90134965927588a5e;hp=8bbd434cd831e51a0ed48e8dcf0409e7edafc4c5;hpb=563bd9812b0eb73ae4e49de012e0f67ed836faaf;p=serve0 diff --git a/pages/view.sh b/pages/view.sh index 8bbd434..fef4f78 100755 --- a/pages/view.sh +++ b/pages/view.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014, 2015 Paul Hänsch +# Copyright 2014 2016 Paul Hänsch # # This file is part of Serve0. # @@ -19,25 +19,28 @@ . $_EXEC/pages/common.sh -info="$_GET[\"i\"]" +info="${_GET[i]}" +location="$(invalidate "${_GET[l]}" '(.*/)?\.\.(/.*)?|' /)" +directory="${location%/*}" + +TITLE="$info" meta="${_DATA}/meta/$info.meta" -video="${_DATA}/videos/$info" +[ -n "$info" ] && video="${_DATA}/videos/$info" \ + || video="${treeroot%/}/${location#/}" tags="$(sed -n '2p' "$meta")" description="$(sed -n '3,$p' "$meta")" length=0; width=0; height=0; -eval $(mplayer -noconsolecontrols -input file=/dev/null -slave -really-quiet -identify -frames 0 -ao null -vo null "$video" 2>/dev/null\ -| sed -rn 's:ID_VIDEO_WIDTH=(.*):width=\1:p;s:ID_VIDEO_HEIGHT=(.*):height=\1:p;s:ID_LENGTH=(.*)(\..*)$:length=\1:p;') -video="videos/$info" -case "$1" in - title) - echo "Videos" - ;; - css) - . ${_EXEC}/templates/common.css.sh - ;; - body) - . ${_EXEC}/templates/view.html.sh - ;; -esac +debug "Analysing video: $video" +printf '' |mplayer -input nodefault-bindings -nosound -vo null -identify -frames 0 "$video" \ +| sort \ +| sed -rn 's:ID_LENGTH=(.*)(\..*)$:\1:p; + s:ID_VIDEO_HEIGHT=(.*):\1:p; + s:ID_VIDEO_WIDTH=(.*):\1:p;' \ +| tr '\n' ' ' \ +| read length height width 2>/dev/null + +video="videos/$info" +[ -n "$info" ] && video="videos/$info" \ + || video="${location#/}"