X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=actions%2Fwatch.sh;h=b0a5920b260535c97295945b2dc3f10abe074490;hb=235877da7d36cb076fcbfed285b54ce967907642;hp=39ca7e0cecd7833e28ec69c1937b7b54cd281aac;hpb=37450b7423b778817c24521e60c6719335d62d26;p=serve0 diff --git a/actions/watch.sh b/actions/watch.sh index 39ca7e0..b0a5920 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -2,17 +2,19 @@ cgi_refdata info="${_GET[i]}" +location="$(invalidate "${_GET[l]}" '(.*/)?\.\.(/.*)?|' /)" order="${_REF[o]}" search="${_REF[s]}" filter="${_REF[f]}" page="${_REF[pn]}" watch_link='' -[ -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}" +[ -n "$location" ] && watch_link="l=$(urlsafe "${location}")&" +[ -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}pn=${page}" meta="${_DATA}/meta/$info.meta" head -n1 "$meta" |read length width height filename @@ -20,20 +22,22 @@ head -n1 "$meta" |read length width height filename [ "$width" -gt 0 ] || width=0 [ "$height" -gt 0 ] || height=0 -linkinfo="$(urlsave "$info")" +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="$(urlsave "mp4/${info%.*}.mp4")" + videourl="$(urlsafe "mp4/${info%.*}.mp4")" +elif [ -z "$info" ]; then + videourl="$(urlsafe "${location#/}")" else - videourl="$(urlsave "videos/$info")" + 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}$(urlsave "http://jupiter:8000/?action=transcode&i=${linkinfo}&t=480")" \ - || redirect "${rpiaddr}$(urlsave "http://jupiter:8000/${videourl}")" + [ $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" \ @@ -47,7 +51,11 @@ case "${_COOKIE[watch]}" in 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 & + if [ -n "$info" ]; then + DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 nohup /usr/bin/mplayer -ao pulse --quiet "${_DATA}/videos/$info" >/dev/null 2>/dev/null & + elif [ -n "$location" ]; then + DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1006 nohup /usr/bin/mplayer -ao pulse --quiet "${treeroot%/}/${location#/}" >/dev/null 2>/dev/null & + fi redirect "$HTTP_REFERER" ;; *) redirect "?p=view&${watch_link}"