X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=actions%2Fwatch.sh;h=2a91ce89b751f976d128f30787c8c21023f96aaa;hb=8d127fe6a7ae92a34d8885a945a36dca1b47211e;hp=65bfecd981215062de7e444894b46a2e232d990e;hpb=f637cbf2d857fd30c80df7b2541e860fe4151775;p=serve0 diff --git a/actions/watch.sh b/actions/watch.sh index 65bfecd..2a91ce8 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -1,17 +1,58 @@ #!/bin/zsh cgi_refdata -info="$_GET[\"i\"]" -order="$_REF[\"o\"]" -search="$_REF[\"s\"]" -filter="$_REF[\"f\"]" -page="$_REF[\"p\"]" +info="${_GET[i]}" +order="${_REF[o]}" +search="${_REF[s]}" +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=$(urlsafe "${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}p=${page}" +[ -n "$page" ] && watch_link="${watch_link}pn=${page}" + +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="$(urlsafe "$info")" + +if [ "${_COOKIE[fakemp4]}" = yes ] && [ "${info##*.}" != mp4 ]; then + [ -e "${_DATA}/videos/${info%.*}.mp4" ] || ln -s "${_DATA}/videos/$info" "${_DATA}/mp4/${info%.*}.mp4" + videourl="$(urlsafe "mp4/${info%.*}.mp4")" +else + videourl="$(urlsafe "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}$(urlsafe "http://jupiter:8000/?action=transcode&i=${linkinfo}&t=480")" \ + || redirect "${rpiaddr}$(urlsafe "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" + ;; + server) + DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 nohup /usr/bin/mplayer -ao pulse --quiet "${_DATA}/videos/$info" >/dev/null 2>/dev/null & + redirect "$HTTP_REFERER" + ;; + *) redirect "?p=view&${watch_link}" + ;; +esac + + -echo -n "Location: ?${watch_link}\n\n"