X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=actions%2Fwatch.sh;h=1ba0954192943b07529c80d842b9670b3639cdf5;hb=c59fd5a4946c4d13fc1692e4561878a9bb2b3e17;hp=dbaa919b027e1276cf6b8468f159ea4eb23e33bc;hpb=7571fa64baa699a0e2cc6d77d9fb69c907ee8d64;p=serve0 diff --git a/actions/watch.sh b/actions/watch.sh index dbaa919..1ba0954 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -9,13 +9,9 @@ search="${_POST[s]}" filter="${_POST[f]}" page="${_POST[pn]}" -watch_link='' +watch_link="${_POST[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 @@ -25,12 +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="w=$(urlsafe "${_GET[return]}")" elif [ -z "$info" ]; then videourl="$(urlsafe "${location#/}")" else @@ -39,8 +41,12 @@ fi case "$_COOKIE[watch]" in raspi) - rpiaddr="http://atoemchen.helmchyn.no-ip.biz/?action=watch&url=" - redirect "${rpiaddr}$(urlsafe "http://${HTTP_HOST}/${videourl}")" + 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" \ @@ -73,19 +79,20 @@ case "$_COOKIE[watch]" in cp "$metafile" "$playmeta" else rm "$playmeta" - "${_EXEC}"/helpers/genmeta.sh "$playuri" "$playmeta" >/dev/null + "${_EXEC}"/helpers/genmeta.sh "$playuri" "$playmeta" >&- fi export DISPLAY=":0" uid="$(id |sed -rn '1s;.*uid=([0-9]+)[^0-9].*;\1;p')" export XDG_RUNTIME_DIR="/run/user/$uid" # required for Pulseaudio - xrandr || true >/dev/null # helps enable all screens + xrandr || true >&- # helps enable all screens + xvkbd -text '\x+10000\y+10000' || true >&- if mplayer |grep -q MPlayer2; then nohup /usr/bin/mplayer \ --slave --input=file="$fifofile" \ --volume="$volume" \ - "$playuri" 2>"$statusfile" >/dev/null & + "$playuri" 2>"$statusfile" >&- & else nohup /usr/bin/mplayer \ -slave -input file="$fifofile" \