]> git.plutz.net Git - serve0/blobdiff - actions/watch.sh
introduced player preferences
[serve0] / actions / watch.sh
index 04c023925962297ffe600556b0e4d40f82d4e6bf..8f1a18d272a04ad3e22fb291e805bcf8a33f379a 100755 (executable)
@@ -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
+
+
+