]> git.plutz.net Git - serve0/blobdiff - actions/watch.sh
styling for pagination links
[serve0] / actions / watch.sh
index 5e0281986541be2e99b7736652e2f1eb9671a22c..1ba0954192943b07529c80d842b9670b3639cdf5 100755 (executable)
@@ -21,13 +21,18 @@ head -n1 "$meta" |read length width height filename
 
 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")"
+if [ "${_COOKIE[fakemp4]}" = yes ]; then
+  fakename="$(printf %s "${info}" |sed -r 's;.*/;;g; s;.[^.]+$;;; s;\.;_;g;')"
+  if [ "$info" != "${fakename}.mp4" ]; then
+    [ -e "${_DATA}/mp4/${fakename}.mp4" ] || ln -s "${_DATA}/videos/$info" "${_DATA}/mp4/${fakename}.mp4"
+    videourl="$(urlsafe "mp4/${fakename}.mp4")"
+  else
+    videourl="$(urlsafe "videos/$info")"
+  fi
 elif [ -n "$foreign" ]; then
   _COOKIE[watch]=server
   videourl="${_GET[url]}"
-  watch_link="${_GET[return]}"
+  watch_link="w=$(urlsafe "${_GET[return]}")"
 elif [ -z "$info" ]; then
   videourl="$(urlsafe "${location#/}")"
 else
@@ -36,8 +41,12 @@ fi
 
 case "$_COOKIE[watch]" in
   raspi)
-    rpiaddr="http://atoemchen.helmchyn.no-ip.biz/?action=watch"
-    redirect "${rpiaddr}&url=$(urlsafe "http://${HTTP_HOST}/${videourl}")&return=$(urlsafe "http://${HTTP_HOST}/?${_POST[page]}")"
+    ncat "$RHOST" "$RPORT" >&- <<-EOF
+       GET /?action=watch&url=$(urlsafe "http://${HTTP_HOST}/${videourl}") HTTP/1.1$(printf \\r)
+       Host: ${RHOST}$(printf \\r)
+       $(printf \\r)
+       EOF
+    redirect "?p=playctl&${watch_link}w=$(urlsafe "${_POST[page]}#${_GET[i]}")"
   ;;
   480p)
     [ $height -gt 480 ] && redirect "?action=transcode&i=${linkinfo}&t=480" \