--- /dev/null
+#!/bin/zsh
+
+if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
+(head -c "${CONTENT_LENGTH}"; echo)|sed 's:&:\n:g;s:\r::g' |while read line; do
+ case "$line" in
+ type[0-9]=neg)
+ [ -z "$filters" ] && filters="!"
+ [ -n "$filters" ] && egrep -q '(^|\^|\||!)$' <<<"$filters" || filters="${filters}^!"
+ ;;
+ type[0-9]=pos)
+ egrep -q '(^|\^|\||!)$' <<<"$filters" || filters="${filters}^"
+ ;;
+ category=*)
+ category="$(sed 's/^category=//;s/+/ /g;s/%/\\x/g' <<<"$line")"
+ category="$(echo -e "${category}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
+ ;;
+ filter=*)
+ filter="$(sed 's/^filter=//;s/+/ /g;s/%/\\x/g' <<<"$line")"
+ filter="$(echo -e "${filter}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
+ egrep -q '(^|\^|\||!)$' <<<"${filters}" || filters="${filters}|"
+ filters="${filters}${filter}"
+ ;;
+ cfilter=*)
+ cfilter="$(sed 's/^cfilter=//;s/+/ /g;s/%/\\x/g' <<<"$line")"
+ cfilter="$(echo -e "${cfilter}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
+ egrep -q '(^|\^|\||!)$' <<<"${filters}" || filters="${filters}|"
+ [ -n "$cfilter" ] && filters="${filters}${category}:${cfilter}"
+ ;;
+ o=Name) order=Name;;
+ o=Date) order=Date;;
+ o=Length) order=Length;;
+ esac
+done
+fi
+
+echo "?o=${order}&f=${filters}" >>${DATA}/meta/recent
+echo -n "Location: ?o=${order}&f=${filters}\n\n"
else
tags="$(sed -n 2p "$meta")"
thumb="${_DATA}/thumbs/$info.jpg"
- head -n1 "$meta" |read length width height
+ head -n1 "$meta" |read length width height filename
[ -z "$length" ] && length=0
[ -z "$width" ] && width=0
[ -z "$height" ] && height=0
-# reenc="vp8/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1:' <<<"$info" )"
+# reenc="${_DATA}/vp8/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1:' <<<"$info" )"
mpfake="${_DATA}/mp4/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1.mp4:' <<<"$info" )"
# [ -f "$reenc.mp4" ] && reenc="$reenc.mp4" || reenc="$reenc.mkv"
[ -r "$meta" ] || ./genmeta.sh "$video" "$meta"
[ -r "$thumb" ] || ./genthumb.sh "$video" "$thumb"
[ -L "$mpfake" ] || ln -s "../$video" "$mpfake"
-# anchor=$(ls videos |grep -xA2 "$info" |tail -n1)
video="$(echo "videos/$info" |sed 's/\?/\%6F/g')"
thumb="$(echo "thumbs/$info.jpg" |sed 's/\?/%6F/g')"
mpfake="$(echo "$info" |sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:mp4/\1.mp4:' |sed 's/\?/%6F/g')"
tee "$cache" <<VIDEOend
<div class="thumb">
- <a name="$info" href="?i=$info&p=$page&f=$filter&s=$search&o=$order#$anchor"><img src="$thumb"></a>
+ <a name="$info" href="?i=$info&p=$page&f=$filter&s=$search&o=$order#$info"><img src="$thumb"></a>
<div class="thumbinfo">
<a href="$video"><b>$info</b></a><br>
<!-- a href="$reenc">VP8</a -->
if [ "$cache" -nt ${_DATA}/videos -a "$cache" -nt ${_DATA}/meta ]; then
cat "$cache"
else
- filterex="p"
+ filterex="q0"
for each in $(sed 's,\^, ,g' <<<"$filter"); do
if egrep -q '^!' <<<"$each"; then
this="$(sed 's,^!,,' <<<"$each")"
- filterex="/${this}/q;{${filterex}}"
+ filterex="/${this}/q1;{${filterex}}"
else
filterex="/${each}/{${filterex}}"
fi
;;
esac
- $genlist |while read video; do
- #video="$(basename "$each")"
- if [ -n "$search" ] ; then
- egrep -iq "$search" <<<"$video" <"${_DATA}/meta/$video.meta" && (echo "$video" || exit 0)
- elif [ "$filterex" != p ]; then
- [ -n "$(sed -rn "2{$filterex}" "${_DATA}/meta/$video.meta")" ] && (echo "$video" || exit 0)
- else
- echo "$video" || exit 0
- fi
- done |sed -n $(($page * $pagesize + 1)),$(($page * $pagesize + $pagesize))p |tee "$cache"
+ if [ -n "$search" ] ; then
+ #$genlist |egrep -i "$search"
+ $genlist |sed -rn 's:^(.+)$:'"${_DATA}"'/meta/\1'.meta':p' |xargs -d\\n egrep -sil "$search" |sed -rn 's:^(.*/)+([^/]+)\.meta$:\2:p'
+ elif [ "$filterex" != "q0" ]; then
+ $genlist |while read video; do
+ [ -r "${_DATA}/meta/$video.meta" ] && sed -rn "2{$filterex;q1}" "${_DATA}/meta/$video.meta" && echo "$video"
+ done
+ else
+ $genlist
+ fi |sed -n $(($page * $pagesize + 1)),$(($page * $pagesize + $pagesize))p |tee "$cache"
fi | while read line; do
_printVideo "$line"
done
cat <<FilterEnd
<div class="panel" id="search" style="display: block;">
- <form action="index.cgi" method="get" accept-charset="UTF-8">
+ <form action="?" method="get" accept-charset="UTF-8">
<input type="text" name="s" value="$search" placeholder="Search">
Order by:<select size="1" name="o">
<option>Name</option>
<a class="panel" href="#" onclick="javascript:hide_block('advfilter');$(for n in {1..9}; do echo "hide_inline('filter$n');"; done)show_block('search')">Hide</a>
<hr>
Up to <b>10</b> filter boxes will appear as you start selecting tags. You can select <b>multiple</b> tags in each box by holding down the <b>Ctrl</b>-key. Click the "<b>Filter!</b>" button when you are ready.
- <form action="filter.cgi" method="post" accept-charset="UTF-8">
+ <form action="?action=filter" method="post" accept-charset="UTF-8">
$(for n in {0..9}; do
hideall="$(sed -rn "s;^([^:]+):.*$;hide_inline('${n}_\\1')\\;;p" <<<"$taglist" |sort -u)hide_inline('${n}_none');"
echo "