X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=actions%2Fwatch.sh;h=c0cdb377c8904d5849335fbdf4b4c834f34f8054;hb=7bf56bff8e30ea23047422e05d1ef5352ea9cc31;hp=d64ae6716550b054f4888c8c05e95019fa43b1d9;hpb=714fa51adcec29b6373f3cd94bc79c1e8dca0d30;p=serve0 diff --git a/actions/watch.sh b/actions/watch.sh index d64ae67..c0cdb37 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -1,17 +1,59 @@ #!/bin/zsh cgi_refdata -info="$_GET[\"i\"]" -order="$_REF[\"o\"]" -search="$_REF[\"s\"]" -filter="$_REF[\"f\"]" -page="$_REF[\"pn\"]" +cgi_cookie +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=$(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: ?page=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" + ;; + server) + DISPLAY=:0 nohup /usr/bin/mplayer -ao pulse:jupiter --quiet "${_DATA}/videos/$info" >&- 2>&- & + redirect "$HTTP_REFERER" + ;; + *) redirect "?p=view&${watch_link}" + ;; +esac + + +