3 # Copyright 2014 Paul Hänsch
5 # This file is part of Serve0.
7 # Serve0 is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # Serve0 is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with Serve0. If not, see <http://www.gnu.org/licenses/>.
21 . ${_EXEC}/templates/filterdiag.html.sh
26 hideall="$(sed -rn "s;^([^:]+):.*$;hide_inline('${n}_\\1')\\;;p" <<<"$taglist" |sort -u)hide_inline('${n}_none');"
28 . ${_EXEC}/templates/tagger.html.sh
32 meta="${_DATA}/meta/$info.meta"
33 video="${_DATA}/videos/$info"
34 #reenc="vp8/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1:' <<<"$info" )"
35 #[ -f "$reenc.mp4" ] && reenc="$reenc.mp4" || reenc="$reenc.mkv"
36 tags="$(sed -n '2p' "$meta")"
37 description="$(sed -n '3,$p' "$meta")"
38 length=0; width=0; height=0;
39 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;')
42 for each in ${_DATA}/meta/*.meta; do
43 sed -n '2s:|:\n:gp' "$each"
44 done |sort -u |grep -xv '')
46 . ${_EXEC}/templates/view.html.sh
51 meta="${_DATA}/meta/$info.meta"
52 tags="$(sed -n 2p "$meta")"
53 thumb="${_DATA}/thumbs/$info.jpg"
54 head -n1 "$meta" |read length width height
55 [ -z "$length" ] && length=0
56 [ -z "$width" ] && width=0
57 [ -z "$height" ] && height=0
59 video="${_DATA}/videos/$info"
60 # reenc="vp8/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1:' <<<"$info" )"
61 mpfake="${_DATA}/mp4/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1.mp4:' <<<"$info" )"
62 # [ -f "$reenc.mp4" ] && reenc="$reenc.mp4" || reenc="$reenc.mkv"
63 [ -r "$meta" ] || ./genmeta.sh "$video" "$meta"
64 [ -r "$thumb" ] || ./genthumb.sh "$video" "$thumb"
65 [ -L "$mpfake" ] || ln -s "../$video" "$mpfake"
66 # anchor=$(ls videos |grep -xA2 "$info" |tail -n1)
67 video="$(echo "$video" |sed 's/\?/\%6F/g')"
68 thumb="$(echo "$thumb" |sed 's/\?/%6F/g')"
69 mpfake="$(echo "$mpfake" |sed 's/\?/%6F/g')"
71 [ "$(($length % 60))" -lt 10 ] &&\
72 minutes="$(($length / 60)):0$(($length % 60))" ||\
73 minutes="$(($length / 60)):$(($length % 60))"
77 <a name="$info" href="?i=$info&p=$page&f=$filter&s=$search&o=$order#$anchor"><img src="$thumb"></a>
78 <div class="thumbinfo">
79 <a href="$video"><b>$info</b></a><br>
80 <!-- a href="$reenc">VP8</a -->
81 <a href="$mpfake">fake-mp4</a><br>
82 <input type="checkbox" name="tagsel" value="$info">
83 <span class="coord">${minutes}min</span>
84 <span class="coord">${width}x${height}</span><br>
85 <!--a class="function" href='write/lock.cgi?p=Locations&e=$info&i=$info&f=$filter#$anchor'>edit</a-->
86 <span class="tag">$(sed 's,|$,,;s,|,</span> <span class="tag">,g' <<<"$tags")</span>
92 _by_name(){ ls ${_DATA}/videos/ }
93 _by_date(){ ls -c ${_DATA}/videos/ }
94 _by_length(){ ls ${_DATA}/by_length/ |sed -r 's:[0-9]{5} - ::g' }
97 cache="${_DATA}/cache/?o=${order}&s=${search}&f=${filter}&p=${page}"
98 [ -f "$cache" ] && [ "$cache" -ot ${_DATA}/videos -o "$cache" -ot ${_DATA}/meta ] && rm "$cache"
99 if [ -r "$cache" ]; then
105 for each in $(sed 's,\^, ,g' <<<"$filter"); do
106 if egrep -q '^!' <<<"$each"; then
107 this="$(sed 's,^!,,' <<<"$each")"
108 filterex="/${this}/q;{${filterex}}"
110 filterex="/${each}/{${filterex}}"
115 Date) genlist="_by_date"
117 Length) genlist="_by_length"
119 *) genlist="_by_name"
123 $genlist |while read video; do
124 #video="$(basename "$each")"
125 if [ -n "$search" ] ; then
126 egrep -iq "$search" <<<"$video" <"${_DATA}/meta/$video.meta" && (echo "$video" || exit 0)
127 elif [ "$filterex" != p ]; then
128 [ -n "$(sed -rn "2{$filterex}" "${_DATA}/meta/$video.meta")" ] && (echo "$video" || exit 0)
130 echo "$video" || exit 0
132 done |sed -n $(($page * $pagesize + 1)),$(($page * $pagesize + $pagesize))p | while read line; do
142 . ${_EXEC}/templates/videoview.css.sh
145 . ${_EXEC}/templates/videoview.html.sh