done
fi
-echo "?o=${order}&f=${filters}" >>${DATA}/meta/recent
+echo "?o=${order}&f=${filters}" >>${_DATA}/meta/recent
echo -n "Location: ?o=${order}&f=${filters}\n\n"
--- /dev/null
+#!/bin/zsh
+
+info="$_GET[\"i\"]"
+file="{$DATA}/meta/$info.meta"
+
+if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
+(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
+ if (egrep -xq 'length=[0-9]{1,5}' <<<"${line}"); then
+ length="$(cut -d= -f2 <<<"${line}")"
+ elif (egrep -xq 'width=[0-9]{1,5}' <<<"${line}"); then
+ width="$(cut -d= -f2 <<<"${line}")"
+ elif (egrep -xq 'height=[0-9]{1,5}' <<<"${line}"); then
+ height="$(cut -d= -f2 <<<"${line}")"
+ elif (egrep -xq 'tag=.+' <<<"${line}"); then
+ tag="$(sed -r 's:^tag=(.*)$:\1:;s:\+:_:g;s:%:\\x:g' <<<"$line")"
+ tag="$(echo -e "${tag}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\<\;/g;s/>/\>\;/g')"
+ tagacc="$tag|$tagacc"
+ elif (egrep -xq 'tags=.+' <<<"${line}"); then
+ tags="$(sed -r 's:^tags=(.*)$:\1:;s:\+:_:g;s:%:\\x:g' <<<"$line")"
+ tags="$(echo -e "${tags}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\<\;/g;s/>/\>\;/g')"
+ elif (egrep -xq 'description=.+' <<<"${line}"); then
+ description="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
+ description="$(echo -e "${description}" |sed 's/\r//g;s/\\/\\\\/g;s/</\<\;/g;s/>/\>\;/g')"
+ elif (egrep -xq 'trash=.+' <<<"${line}"); then
+ trash="true"
+ elif (egrep -xq 'cancel=.+' <<<"${line}"); then
+ cancel="true"
+ elif (egrep -xq 'f=.+' <<<"${line}"); then
+ filter="$(cut -d= -f2- <<<"${line}")"
+ elif (egrep -xq 's=.+' <<<"${line}"); then
+ search="$(cut -d= -f2- <<<"${line}")"
+ elif (egrep -xq 'p=.+' <<<"${line}"); then
+ page="$(cut -d= -f2- <<<"${line}")"
+ elif (egrep -xq 'o=.+' <<<"${line}"); then
+ order="$(cut -d= -f2- <<<"${line}")"
+ fi
+done
+fi
+
+[ -z "$cancel" ] && if [ "$trash" = "true" ]; then
+ rm "${_DATA}/thumbs/$info.jpg" 2>/dev/null
+ mv "${_DATA}/videos/$info" "${_DATA}/meta/$info.meta" "${_DATA}/trash/" 2>/dev/null
+ rm "${_DATA}/cache/$info.cache" 2>/dev/null
+ rm ${_DATA}/cache/\?* 2>/dev/null
+else
+ echo -e "$length\t$width\t$height\t$info" > "$file"
+ echo -e "${tagacc}${tags}" |tr '\n' '|' >> "$file"
+ echo >>"$file"
+ echo -e "${description}" >> "$file"
+ rm "${_DATA}/cache/$info.cache" 2>/dev/null
+ rm ${_DATA}/cache/\?* 2>/dev/null
+fi
+
+echo -n "Location: index.cgi?i=&p=${page}&s=${search}&f=${filter}&o=${order}#$info\n\n"
--- /dev/null
+#!/bin/zsh
+
+addtag(){
+ meta="$1"
+ tag="$2"
+
+ length=0; width=0; height=0;
+ if [ -r "$meta" ]; then
+ head -n1 "$meta" |read length width height info
+ tags="$(sed -n 2p "$meta" |sed -r 's:^\|(.*)$:\1:')"
+ description="$(sed -n '3,$p' "$meta")"
+ fi
+
+ egrep -q "(^|.*\|)$tag(\|.*|$)" <<<"$tags" || tags="$tag|$tags"
+
+ cat <<EOF >"$meta"
+$length $width $height $info
+$tags
+$description
+EOF
+}
+
+n=0
+if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
+(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
+ if expr "$line" : "tagsel=" >/dev/null; then
+ n=$(($n + 1))
+ tagsel[$n]="$(echo -e "$(sed -nr 's:(^|&)tagsel=(.*)(&|$):\2:;s:&.*$::;s:\+: :g;s:%:\\x:g;p' <<<"$line" )")"
+ elif expr "$line" : "ctag=" >/dev/null; then
+ tag="$(sed -r 's:^ctag=(.*)$:\1:;s:\+:_:g;s:%:\\x:g' <<<"$line")"
+ tag="$(echo -e "${tag}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\<\;/g;s/>/\>\;/g')"
+ for i in {1..$n}; do
+ addtag "${_DATA}/meta/$tagsel[$i].meta" "$tag"
+ rm "${_DATA}/cache/$tagsel[$i].cache" 2>/dev/null
+ done
+ elif expr "$line" : 'tags=.\+' >/dev/null; then
+ tags="$(sed -r 's:^tags=(.*)$:\1:;s:\+:_:g;s:%:\\x:g' <<<"$line")"
+ tags="$(echo -e "${tags}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\<\;/g;s/>/\>\;/g')"
+ for i in {1..$n}; do echo "$tags" |while read tag; do
+ addtag "${_DATA}/meta/$tagsel[$i].meta" "$tag"
+ rm "${_DATA}/cache/$tagsel[$i].cache" 2>/dev/null
+ done; done
+ fi
+done
+fi
+
+rm ${_DATA}/cache/\?* 2>/dev/null
+
+echo -n "Location: index.cgi?${QUERY_STRING}#$info\n\n"
--- /dev/null
+#!/bin/zsh
+
+dir="$(dirname $0)"
+genmeta="$dir/genmeta.sh"
+genthumb="$dir/genthumb.sh"
+. "$dir/../constants.sh"
+
+addtag(){
+ meta="$1"
+ info="$(basename "$1" |sed -r 's:^(.+)\.meta$:\1:')"
+ tag="$2"
+
+ length=0; width=0; height=0;
+ if [ -r "$meta" ]; then
+ head -n1 "$meta" |read length width height info
+ tags="$(sed -n 2p "$meta" |sed -r 's:^\|(.*)$:\1:')"
+ description="$(sed -n '3,$p' "$meta")"
+ fi
+
+ egrep -q "(^|.*\|)$tag(\|.*|$)" <<<"$tags" || tags="$tag|$tags"
+
+ cat <<EOF >"$meta"
+$length $width $height $info
+$tags
+$description
+EOF
+}
+
+
+for each in *; do
+if (egrep -q "$file_pattern" <<<"$each"); then
+ echo -n "$each ... Thumb ..."
+ $genthumb "$each" "${each}.jpg"
+ echo -n ' Meta ...'
+ $genmeta "$each" "${each}.meta"
+ echo -n ' Tags ...'
+ for tag in $*; do
+ addtag "${each}.meta" "$tag"
+ done
+ echo ' Done!'
+fi; done
--- /dev/null
+#!/bin/zsh
+
+video="$1"
+meta="$2"
+
+if [ -r "$meta" ]; then
+ tags="$(sed -n 2p "$meta")"
+ description="$(sed -n '3,$p' "$meta")"
+fi
+
+eval $(mplayer -noconsolecontrols -input file=/dev/null -slave -really-quiet -identify -frames 0 -ao null -vo null "$video" |sed -rn 's:ID_VIDEO_WIDTH=(.*):width=\1:p;s:ID_VIDEO_HEIGHT=(.*):height=\1:p;s:ID_LENGTH=(.*)(\..*)$:length=\1:p;')
+
+[ -z "$tags" ] && tags='|'
+
+cat <<EOF >"$meta"
+$length $width $height $(basename "$video")
+$tags
+$description
+EOF
--- /dev/null
+#!/bin/zsh
+
+video="$1"
+thumb="$2"
+
+eval $(mplayer -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;')
+
+[ -z "$length" -o -z "$width" -o -z "$height" ] && exit 0
+
+if [ "$(($height*1000/$width))" -gt "750" ]; then
+ width="$((75*$width/$height))"
+ height=75
+else
+ height="$((100*$height/$width))"
+ width=100
+fi
+[ -z $width ] && width=100
+[ -z $height ] && height=100
+chunk="$(($length / 5))"
+
+for cnt in 1 2 3 4; do
+ debug mplayer -nosound -vo jpeg -frames 10 -vf "scale=$width:$height" -ss "$(($cnt*$chunk))" "$video"
+ mplayer -nosound -vo jpeg -frames 10 -vf "scale=$width:$height" -ss "$(($cnt*$chunk))" "$video" >/dev/null 2>/dev/null &
+ mpid="$!"; watch=0
+ while (ps -p "$mpid" >/dev/null 2>/dev/null); do
+ [ "$watch" -gt 10 ] && kill -9 "$mpid" || sleep 1
+ watch="$(($watch+1))"
+ done
+ cp -f 00000009.jpg "${thumb}-${cnt}.jpg" 2>/dev/null
+done
+montage "${thumb}-"[1234]".jpg" -tile 2x2+0+0 -geometry 100x75+3+3 -background "#000000" "${thumb}" 2>/dev/null
+rm 000000[01][0-9].jpg "${thumb}-"[1234]".jpg" 2>/dev/null
+
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"
. ${_EXEC}/templates/view.html.sh
fi
}
# 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"
+ [ -r "$meta" ] || ". ${_EXEC}/helpers/genmeta.sh" "$video" "$meta"
+ [ -r "$thumb" ] || ". ${_EXEC}/helpers/genthumb.sh" "$video" "$thumb"
[ -L "$mpfake" ] || ln -s "../$video" "$mpfake"
video="$(echo "videos/$info" |sed 's/\?/\%6F/g')"
thumb="$(echo "thumbs/$info.jpg" |sed 's/\?/%6F/g')"
cat <<EOF
$(filterdiag)
$(view)
- <form action="multitag.cgi?f=$filter&s=$search&p=$page&o=$order" method="post" accept-charset="UTF-8">
+ <form action="?action=multitag&f=$filter&s=$search&p=$page&o=$order" method="post" accept-charset="UTF-8">
<div style="overflow:hidden;">$(thumblist)</div>
$(tagger)
</form>
</div>
<div class="videoinfo" id="editmeta" style="display: none;">
- <form action="meta.cgi?$info" method="post" accept-charset="UTF-8">
- <input type="hidden" name="f" value="$filter"> <input type="hidden" name="s" value="$search"> <input type="hidden" name="p" value="$page">
+ <form action="?action=meta&i=$info" method="post" accept-charset="UTF-8">
+ <input type="hidden" name="f" value="$filter"> <input type="hidden" name="s" value="$search"> <input type="hidden" name="p" value="$page"> <input type="hidden" name="o" value="$order">
<input type="hidden" name="length" value="$length"> <input type="hidden" name="width" value="$width">
<input type="hidden" name="height" value="$height">
<b>$info</b><a class="panel" href="#" onclick="javascript:hide_inline('editmeta');show_inline('viewmeta')">Cancel</a><br>