From adb56ff5eb6600d4b3bded25989cdb3771d48660 Mon Sep 17 00:00:00 2001 From: bearkillerPT <59414986+bearkillerPT@users.noreply.github.com> Date: Mon, 27 Jan 2020 13:37:33 +0000 Subject: [PATCH 1/4] cvlc example without youtube-dl Working with cvlc and gotubecast. The seek function is currently not working. --- examples/vlcCostum.sh | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 examples/vlcCostum.sh diff --git a/examples/vlcCostum.sh b/examples/vlcCostum.sh new file mode 100644 index 0000000..9a36ffd --- /dev/null +++ b/examples/vlcCostum.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# simple YouTube TV for Raspberry Pi +# kills any currently playing video as soon as a new video is queued +# ONLY NEEDS cvlc no need for youtube-dl +# Made this script out of the already existing raspi.sh +# by bearkillerPT :) +# +# Everything working but the Seek functionality... Specs: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html +# I'll keep trying to implement it but keep in mind that the Property in Mediaplayer2.Player.Postion is read only... +# Omxplayer wassn't working on my rasp and so this way you can also drop the youtube-dl dependecy + +export SCREEN_ID="" +export SCREEN_NAME="Raspberry Pi" +export SCREEN_APP="pitubecast-v1" +export OMX_OPTS="-o hdmi" +export VOL="1.0" + + +function omxdbus { + dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 $* +} + +gotubecast -s "$SCREEN_ID" -n "$SCREEN_NAME" -i "$SCREEN_APP" | while read line +do + cmd="`cut -d ' ' -f1 <<< "$line"`" + arg="`cut -d ' ' -f2 <<< "$line"`" + case "$cmd" in + pairing_code) + echo "Your pairing code: $arg" + ;; + remote_join) + cut -d ' ' -f3- <<< "$line connected" + ;; + video_id) + echo "you/$arg" + sleep 5 + killall -9 vlc + cvlc "http://youtu.be/$arg" /dev/null + ;; + stop) + omxdbus org.mpris.MediaPlayer2.Player.Stop >/dev/null + ;; + seek_to) + pos= omxdbus org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Position >/dev/null + offset=$(($arg-$pos)) + offset=$(($offset*1000000)) + echo "$offset" + omxdbus org.mpris.MediaPlayer2.Player.Seek int64:$offset >/dev/null + + ;; + set_volume) + VOL= omxdbus org.mpris.MediaPlayer2.Player.Volume >/dev/null + #echo $VOL + if [ $arg -lt 100 ]; then + VOL=`echo $arg / 100 | bc -l | awk '{printf "%0.2f\n", $1}'` + fi + echo "try: " $VOL + omxdbus org.freedesktop.DBus.Properties.Set string:org.mpris.MediaPlayer2.Player string:Volume variant:double:$VOL >/dev/null + ;; + esac +done From 5df592488ba2fb2c023d60b730fcdd5f5c6928d1 Mon Sep 17 00:00:00 2001 From: bearkillerPT <59414986+bearkillerPT@users.noreply.github.com> Date: Thu, 30 Jan 2020 12:51:30 +0000 Subject: [PATCH 2/4] Seek function implemented! Seek function implemented with a little bit of abuse there because wasn't able to put method_return of DBus into a var --- examples/vlcCostum.sh | 57 ++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/examples/vlcCostum.sh b/examples/vlcCostum.sh index 9a36ffd..9c3f632 100644 --- a/examples/vlcCostum.sh +++ b/examples/vlcCostum.sh @@ -5,19 +5,32 @@ # Made this script out of the already existing raspi.sh # by bearkillerPT :) # -# Everything working but the Seek functionality... Specs: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html -# I'll keep trying to implement it but keep in mind that the Property in Mediaplayer2.Player.Postion is read only... +# Everything working kinda fine now... Specs: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html +# Finally managed to get it working though I'm having some issues with vlc not keeping up? Might be a connection issue: +# Log: +# [61cc0ad8] main decoder error: buffer deadlock prevented +# [00a50b70] main audio output warning: buffer too late (-27547070 us): dropped +# [00a50b70] pulse audio output warning: starting late (-30195 us) +# [00a50b70] main audio output warning: playback too late (125949): up-sampling # Omxplayer wassn't working on my rasp and so this way you can also drop the youtube-dl dependecy export SCREEN_ID="" export SCREEN_NAME="Raspberry Pi" export SCREEN_APP="pitubecast-v1" export OMX_OPTS="-o hdmi" -export VOL="1.0" +#export POS="1" function omxdbus { - dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 $* + dbus-send --type=method_call --reply-timeout=12000 --print-reply --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 $* +} + +function mult1000 () { + local floor=${1%.*} + [[ $floor = "0" ]] && floor='' + local frac='0000' + [[ $floor != $1 ]] && frac=${1#*.}$frac + POS=$(( ${floor}${frac:0:3} )) } gotubecast -s "$SCREEN_ID" -n "$SCREEN_NAME" -i "$SCREEN_APP" | while read line @@ -30,13 +43,12 @@ do ;; remote_join) cut -d ' ' -f3- <<< "$line connected" - ;; + ;; video_id) - echo "you/$arg" - sleep 5 - killall -9 vlc - cvlc "http://youtu.be/$arg" /dev/null ;; @@ -44,21 +56,20 @@ do omxdbus org.mpris.MediaPlayer2.Player.Stop >/dev/null ;; seek_to) - pos= omxdbus org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Position >/dev/null - offset=$(($arg-$pos)) - offset=$(($offset*1000000)) - echo "$offset" - omxdbus org.mpris.MediaPlayer2.Player.Seek int64:$offset >/dev/null - - ;; + echo "Set Position: "$arg + mult1000 $arg + (( POS=$POS*1000 )) + STARTAGAIN64BIT=$(( -9223372036854775808 )) + omxdbus org.mpris.MediaPlayer2.Player.Seek int64:$STARTAGAIN64BIT >/dev/null + omxdbus org.mpris.MediaPlayer2.Player.Seek int64:$POS >/dev/null + #Here had to abuse seek function.... + ;; set_volume) - VOL= omxdbus org.mpris.MediaPlayer2.Player.Volume >/dev/null - #echo $VOL - if [ $arg -lt 100 ]; then + if [ $arg -lt 100 ]; then VOL=`echo $arg / 100 | bc -l | awk '{printf "%0.2f\n", $1}'` fi - echo "try: " $VOL - omxdbus org.freedesktop.DBus.Properties.Set string:org.mpris.MediaPlayer2.Player string:Volume variant:double:$VOL >/dev/null - ;; + echo "Set Volume: " $VOL + omxdbus org.freedesktop.DBus.Properties.Set string:org.mpris.MediaPlayer2.Player string:Volume variant:double:$VOL >/dev/null + ;; esac done From 0cbde6ebd8a1440e6123bc50582392c9afb378fd Mon Sep 17 00:00:00 2001 From: bearkillerPT <59414986+bearkillerPT@users.noreply.github.com> Date: Thu, 30 Jan 2020 13:39:16 +0000 Subject: [PATCH 3/4] Windows script too auto ssh into the raspberry and run vlcCostum.sh Auto ssh into the raspberry and run vlcCostum.sh (you can change any and everything) Needs: Everything vlcCostum.sh needs; Enable ssh on your raspberrypi and download the putty Client; Config paths / ssh credentials on this files. --- examples/configpipath.txt | 4 ++++ examples/youtubePI.bat | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 examples/configpipath.txt create mode 100644 examples/youtubePI.bat diff --git a/examples/configpipath.txt b/examples/configpipath.txt new file mode 100644 index 0000000..3fadff0 --- /dev/null +++ b/examples/configpipath.txt @@ -0,0 +1,4 @@ +#this are the default(except it's in a folder /home/pi/youtube) this is the script that's run inside the ssh connection to run the script! +echo we in +cd youtube/gotubecast +bash vlcCostum.sh diff --git a/examples/youtubePI.bat b/examples/youtubePI.bat new file mode 100644 index 0000000..886d891 --- /dev/null +++ b/examples/youtubePI.bat @@ -0,0 +1,11 @@ +#This is also a configo file. +#SSH credentials can be modified here too +# SSH needs also putty on windows ::)))))))))) +#Defaultraspbian ssh credentials with the MY rasp's ip on MY router (enable ssh if you don't already have and check it's ip): +set login=pi@192.168.1.79 +set pass=raspberry +set app_path=youtube/gotubecast/examples/ +set app_name=vlcCostum.sh +ECHO \n +ECHO IMMA GET SOME YOUTUBE ACTION ON U LIL PI +putty.exe -ssh %login% -pw %pass% -m .\configpipath.txt \ No newline at end of file From dcec23c97f6240b313b0cb3bbba7f27a33af5d60 Mon Sep 17 00:00:00 2001 From: bearkillerPT <59414986+bearkillerPT@users.noreply.github.com> Date: Thu, 30 Jan 2020 17:15:08 +0000 Subject: [PATCH 4/4] Documentation Simple explanation of the example files. --- examples/readme.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/readme.txt diff --git a/examples/readme.txt b/examples/readme.txt new file mode 100644 index 0000000..7a05210 --- /dev/null +++ b/examples/readme.txt @@ -0,0 +1,20 @@ +"Documentation"! + +Files and what they're for: + +On the raspberry: + -dumb.sh - default implementation in shell with gotubecast; + -raspi.sh - implementation in shell with gotubecast, omxplayer and youtube-dl; + -vlcCostum.sh - implementation in shell with gotubecast and cvlc (vlc without GUI); + +Now if you want to automate the process, with Windows: + -youtubePI.bat - auto open ssh and run commands on configyoutubepipath.txt + -configyoutubepipath.txt - cd into thhe right folders and run + Needs: + - Enable ssh on your raspberry and discover it's ip. + - Edit youtubePI.bat with the ip for ssh and it's credentials if you have changed them already. + - Edit configyoutubepipath.txt with the commands on ssh that you might need to open vlcCostum.sh / raspi.sh if you want. + + +-BearkillerPT +