From: paul Date: Fri, 31 Jul 2015 15:42:27 +0000 (+0000) Subject: introduced player preferences X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=0619bc447c21ac196734848ae3b0aa786b6eb1ee;p=serve0 introduced player preferences svn path=/trunk/; revision=68 --- diff --git a/actions/preferences.sh b/actions/preferences.sh new file mode 100755 index 0000000..1b76fbc --- /dev/null +++ b/actions/preferences.sh @@ -0,0 +1,16 @@ +#!/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" diff --git a/actions/watch.sh b/actions/watch.sh index 04c0239..8f1a18d 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -1,6 +1,7 @@ #!/bin/zsh cgi_refdata +cgi_cookie info="${_GET[i]}" order="${_REF[o]}" search="${_REF[s]}" @@ -8,10 +9,47 @@ filter="${_REF[f]}" 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 + + + diff --git a/pages/common.sh b/pages/common.sh index b424dff..9e659bf 100755 --- a/pages/common.sh +++ b/pages/common.sh @@ -62,37 +62,21 @@ _printVideo(){ 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="RasPi" \ - || raspi="RasPi" - [ $height -gt 480 ] && \ - alt480="480p" \ - ||unset alt480 - [ $height -gt 240 ] && \ - alt240="240p" \ - ||unset alt240 + [ "$(($length % 60))" -lt 10 ] && minutes="$(($length / 60)):0$(($length % 60))" \ + || minutes="$(($length / 60)):$(($length % 60))" tee "$cache" < - + Preview not yet available - $info - ${alt480} ${alt320} ${alt240} ${raspi}
+

$info

${minutes}min ${width}x${height} - $(echo -E "$tags" |sed -r 's:\|*([^|]+)\|*:\1:g') - + $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*:\1:g') + VIDEOend fi } diff --git a/pages/list.sh b/pages/list.sh index a86f04c..32b4b94 100755 --- a/pages/list.sh +++ b/pages/list.sh @@ -17,6 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with Serve0. If not, see . +cgi_cookie . $_EXEC/pages/common.sh filters="$(printf %s "${_GET[f]}" |sed -r 's;^!*\^*;;; s;\^*!*$;;; s;!+;!;g; s;\^+;^;g')" diff --git a/templates/common.css.sh b/templates/common.css.sh index 02d02f3..706ac85 100755 --- a/templates/common.css.sh +++ b/templates/common.css.sh @@ -169,6 +169,11 @@ a.clearsearch, a.advanced, a.tagger, .pagination_nav { #thumblist .thumb img { width: 100%; } +#thumblist .thumb h2 { + font-size: 1em; + font-weight: normal; + margin: 0; +} #thumblist .thumb a { display: block; } @@ -187,6 +192,8 @@ a.clearsearch, a.advanced, a.tagger, .pagination_nav { top: 0; } +#preferences { display: none; } +#preferences:target { display: block; z-index: 1; } #tagger { display: none; } #tagger:target { display: block; z-index: 1; } .footer { diff --git a/templates/list.html.sh b/templates/list.html.sh index a4e50bb..65a1e26 100755 --- a/templates/list.html.sh +++ b/templates/list.html.sh @@ -48,8 +48,11 @@ cat < + $(. $_EXEC/templates/preferences.html.sh) +