--- /dev/null
+#!/bin/zsh
+
+cgi_post
+cgi_cookie
+
+fakemp4="$(printf %s "${_POST[fakemp4]}" |sed -rn '/^yes$/{p;q};ano' )"
+watch="$(printf %s "${_POST[watch]}" |sed -rn '/^(240p|480p|download|raspi|player)$/{p;q};aplayer' )"
+
+debug '== Setting Preferences =='
+debug "fakemp4 = $fakemp4"
+debug "watch = $watch"
+
+set_cookie '+ 1 month' "fakemp4=${fakemp4}" HttpOnly
+set_cookie '+ 1 month' "watch=${watch}" HttpOnly
+
+redirect "$HTTP_REFERER"
#!/bin/zsh
cgi_refdata
+cgi_cookie
info="${_GET[i]}"
order="${_REF[o]}"
search="${_REF[s]}"
page="${_REF[pn]}"
watch_link=''
-[ -n "$info" ] && watch_link="i=$(echo -n "${info}" |sed -r 's:%:%25:g;s:\&:%26:g;')&"
+[ -n "$info" ] && watch_link="i=$(urlsave "${info}")&"
[ -n "$order" ] && watch_link="${watch_link}o=${order}&"
[ -n "$search" ] && watch_link="${watch_link}s=${search}&"
[ -n "$filter" ] && watch_link="${watch_link}f=${filter}&"
[ -n "$page" ] && watch_link="${watch_link}pn=${page}"
-echo -n "Location: ?p=view&${watch_link}\n\n"
+meta="${_DATA}/meta/$info.meta"
+head -n1 "$meta" |read length width height filename
+[ "$length" -gt 0 ] || length=0
+[ "$width" -gt 0 ] || width=0
+[ "$height" -gt 0 ] || height=0
+
+linkinfo="$(urlsave "$info")"
+
+if [ "${_COOKIE[fakemp4]}" = yes ] && [ "${info##*.}" != mp4 ]; then
+ [ -e "${_DATA}/videos/${info%.*}.mp4" ] || ln -s "${_DATA}/videos/$info" "${_DATA}/mp4/${info%.*}.mp4"
+ videourl="$(urlsave "mp4/${info%.*}.mp4")"
+else
+ videourl="$(urlsave "videos/$info")"
+fi
+
+case "${_COOKIE[watch]}" in
+ raspi)
+ rpiaddr="http://pfostenpanne.helmchyn.no-ip.biz/?player=play&path="
+ [ $height -gt 480 -a $width -gt 480 ] && redirect "${rpiaddr}$(urlsave "http://jupiter:8000/?action=transcode&i=${linkinfo}&t=480")" \
+ || redirect "${rpiaddr}$(urlsave "http://jupiter:8000/${videourl}")"
+ ;;
+ 480p)
+ [ $height -gt 480 ] && redirect "?action=transcode&i=${linkinfo}&t=480" \
+ || redirect "$videourl"
+ ;;
+ 240p)
+ [ $height -gt 240 ] && redirect "?action=transcode&i=${linkinfo}&t=240" \
+ || redirect "$videourl"
+ ;;
+ download)
+ redirect "$videourl"
+ ;;
+ *) redirect "?p=view&${watch_link}"
+ ;;
+esac
+
+
+
thumb="$(urlsave "thumbs/$info.jpg")"
linkinfo="$(urlsave "$info")"
- [ "$(($length % 60))" -lt 10 ] &&\
- minutes="$(($length / 60)):0$(($length % 60))" ||\
- minutes="$(($length / 60)):$(($length % 60))"
-
- rpiaddr="pfostenpanne.helmchyn.no-ip.biz"
- rpidull="http://${rpiaddr}/?player=play&path=http://jupiter:8000/${video}"
- rpicgi="http://${rpiaddr}/?player=play&path=$(urlsave "http://jupiter:8000/?action=transcode&i=${linkinfo}&t=480")"
-
- [ $height -gt 480 -a $width -gt 480 ] && \
- raspi="<a class=\"videolink alt raspi\" href=\"${rpicgi}\">RasPi</a>" \
- || raspi="<a class=\"videolink alt raspi\" href=\"${rpidull}\">RasPi</a>"
- [ $height -gt 480 ] && \
- alt480="<a class=\"videolink alt 480p\" href=\"?action=transcode&i=${linkinfo}&t=480\">480p</a>" \
- ||unset alt480
- [ $height -gt 240 ] && \
- alt240="<a class=\"videolink alt 240p\" href=\"?action=transcode&i=${linkinfo}&t=240\">240p</a>" \
- ||unset alt240
+ [ "$(($length % 60))" -lt 10 ] && minutes="$(($length / 60)):0$(($length % 60))" \
+ || minutes="$(($length / 60)):$(($length % 60))"
tee "$cache" <<VIDEOend
<li class="thumb">
<a class="watchlink" name="${linkinfo}" href="?action=watch&i=${linkinfo}">
- <img src="$thumb">
+ <img src="$thumb" alt="Preview not yet available">
</a>
- <a class="videolink" href="$video">$info</a>
- ${alt480} ${alt320} ${alt240} ${raspi}<br>
+ <h2>$info</h2>
<input type="checkbox" name="tagsel" value="$info">
<span class="info property">${minutes}min</span>
<span class="info property">${width}x${height}</span>
- $(echo -E "$tags" |sed -r 's:\|*([^|]+)\|*:<span class="info tag">\1</span>:g')
- </div>
+ $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*:<span class="info tag">\1</span>:g')
+ </li>
VIDEOend
fi
}
# You should have received a copy of the GNU Affero General Public License
# along with Serve0. If not, see <http://www.gnu.org/licenses/>.
+cgi_cookie
. $_EXEC/pages/common.sh
filters="$(printf %s "${_GET[f]}" |sed -r 's;^!*\^*;;; s;\^*!*$;;; s;!+;!;g; s;\^+;^;g')"
#thumblist .thumb img {
width: 100%;
}
+#thumblist .thumb h2 {
+ font-size: 1em;
+ font-weight: normal;
+ margin: 0;
+}
#thumblist .thumb a {
display: block;
}
top: 0;
}
+#preferences { display: none; }
+#preferences:target { display: block; z-index: 1; }
#tagger { display: none; }
#tagger:target { display: block; z-index: 1; }
.footer {
$(. $_EXEC/templates/tagger.html.sh)
</form>
+ $(. $_EXEC/templates/preferences.html.sh)
+
<div class="panel footer" id="foot">
<a class="panel tagger show" href="#tagger">Add Tags</a>
+ <a class="panel tagger show" href="#preferences">Preferences</a>
<div class="pagination_nav">
<label>Page:</label>
--- /dev/null
+# Copyright 2015 Paul Hänsch
+#
+# This file is part of Serve0
+#
+# Serve0 is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Serve0 is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Serve0 If not, see <http://www.gnu.org/licenses/>.
+
+cat <<EOF
+ <form class="panel footer" id="preferences"
+ action="?action=preferences" method="post" accept-charset="UTF-8">
+ <a class="panel hide" href="#foot">Hide</a>
+
+ <input type="checkbox" name="fakemp4" value="yes" $([ "${_COOKIE[fakemp4]}" = yes ] && printf 'checked') id="ck_fakemp4">
+ <label for="ck_fakemp4">Fake .mp4 file ending, even if file is of different type</label>
+
+ <h2>Watch videos:</h2>
+ <input type="radio" name="watch" value="240p" $([ "${_COOKIE[watch]}" = 240p ] && printf 'checked') id="rd_w240p">
+ <label for="rd_w240p">as Download in 240p</label><br>
+ <input type="radio" name="watch" value="480p" $([ "${_COOKIE[watch]}" = 480p ] && printf 'checked') id="rd_w480p">
+ <label for="rd_w480p">as Download in 480p</label><br>
+ <input type="radio" name="watch" value="download" $([ "${_COOKIE[watch]}" = download ] && printf 'checked') id="rd_wdown">
+ <label for="rd_wdown">as Download (original)</label><br>
+ <input type="radio" name="watch" value="raspi" $([ "${_COOKIE[watch]}" = raspi ] && printf 'checked') id="rd_wrasp">
+ <label for="rd_wrasp">on RaspBerry</label><br>
+ <input type="radio" name="watch" value="player" $([ "${_COOKIE[watch]}" = player ] && printf 'checked') id="rd_wplay">
+ <label for="rd_wplay">in embedded player</label><br>
+
+ <input type="submit" value="Set Cookie!">
+ </form>
+EOF
+
+# vi:set filetype=html: