Raspberry Pi

I’ve hacked together a quick implementation along the new lines of thought here (i.e. interfaceless player that appears as a player you can choose in iOS).



I stress how bare-bones it is, but I think it should be pretty simple to add to. Of particular note, there is no way to cleanly stop any media you play, or even stop the client itself.





wow, this seems awesome. will try this when i'm back home on monday. Also going to see if i can help you with the code you already have, making it able to listen to play, pauze and stop commands (and more stuff like that) would be a nice challenge.


Those should just be extra commands to add, similar to the 'PlayMedia' command which is already there. I wasn't able to see any of the remote commands being passed to my client, though, other than 'changevolume'. I was having difficulty with NAT loopback failing at one point though, so it could be that.

Without much (read: any) python experience, I’m going to ask this for all the beginners that want to try this out.



Where should this be run, and how?



(Example: Terminal? inside an X Windows environment? Can it run in the background of Raspbmc or OpenELEC, or does XBMC have to be closed first?)





I’m really excited that this may be the seed that grows a basic python UI :slight_smile:



i've got it running on my rs-pi running debian weezy!
here are the steps i had to go through:

<br />
sudo apt-get update && sudo apt-get upgrade<br />
sudo wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update<br />
sudo cp rpi-update /usr/local/bin/rpi-update<br />
sudo chmod +x /usr/local/bin/rpi-update <br />
sudo rpi-update 192<br />
sudo reboot<br />
sudo vim config.txt > to set arm_freq to 1000<br />
sudo reboot<br />
mkdir Apps<br />
cd Apps/<br />
git clone git://github.com/area/pyplex.git<br />
sudo apt-get install avahi-daemon<br />
sudo apt-get install python-pip<br />
sudo pip install web.py<br />
cd pyplex/<br />
sudo pip install pexpect<br />
sudo apt-get install python-avahi <br />
python pyplex.py 3000<br />



hook it up to a monitor and hit "play on Raspberry Plex" and it'll start playing!

I have to say, this is really really awesome! Can't wait to dig into the code and make it have more functionality's

Been digging around the code trying to figure out how to listen to play and pauze commands. Found out that the server actually sends a command to the rs-pi



<br />
Oct 22, 2012 19:22:55 [0xf2ab1b90] DEBUG - HTTP requesting to: http://127.0.0.1:58330/system/players/192.168.1.216/playback/pause<br />





but i have not yet found a way to listen to those calls :( been trying to setup sockets but without result so far. Does someone has any idea how to implement this?

i did add omx.stop() at line 96 to stop the current file playing if you select another file. Without it it'll play both.
--- edit ---It seems I added omx.stop while the script was still running, when i restarted the script it crasheshed when selecting a file to watch.


Hi there,

I would like to start with pyplex and would like to increase the codebase but the client doesn't start correctly. I followed your steps and tested my own stuff but every time i get the same result:

Service published<br />
http://0.0.0.0:3000/



Had anyone the same problem? Could it be something with my home network?

Best regards,
emha

This may be way off the mark, but one note:

At least in Linux operating systems, when an application binds to 0.0.0.0, it is listening on all IP addresses associated with the system (multiple ips are useful for network filtering, and can happen incidentally for various reasons)



Point being, have you tested it when it says that?



Thank you I didn't know that.I'm able to access via browser and the ip+port and get "Hello World" but in my plex ios app my raspberry is not listed as client.

Is there a way to turn that off? (listening on all ports) static ip address? deactivate dhcp?

Hey, I have to look into the ip thing. With me when it says published on 0.0.0.0:3000 it shows up as a a player under my iPhone/iPad clients. Can you look at your server logs when you start the pyplex? It should say that there is a new client.

On an other note, I've been working with the code the last week and I've added a view goodies.

1. addad a "screen saver" plex picture when it's not playing any files
2. added a function to tell if omx player is running. And a killomx function to kill it before you start a new file.
3. it tells the server the progress of the file played

You can find it here: github.com/megawubs/pyplex

One of the biggest challenge for me is to listen to play, pause and stop commands. Because they are not send to port 3000 but to port 80 so it has to listen to both.

--- edit

[s]I don't think I've committed and pushed number 2 and 3 to github yet. Will do it as soon as I get home.[/s]

Hey JiK,



I’ve looke at the log and get the following output:


Oct 28, 2012 15:38:34 [0xb08a1000] DEBUG - Server found (Raspberry Plex), resolving...<br />
Oct 28, 2012 15:38:34 [0xb08a1000] DEBUG - Server resolved: raspberrypi.local. (Raspberry Plex)<br />
Oct 28, 2012 15:38:34 [0xb08a1000] DEBUG - Updating TXT record (success=Yes)<br />
Oct 28, 2012 15:38:34 [0xb08a1000] DEBUG - TXT record updated: Raspberry Plex<br />
Oct 28, 2012 15:38:35 [0xb08a1000] DEBUG - TXT record updated: Maltes MacBook Air<br />
Oct 28, 2012 15:38:35 [0xb08a1000] DEBUG - TXT record updated: Maltes MacBook Air<br />
Oct 28, 2012 15:38:35 [0xb0c40000] DEBUG - Notifying the system bundle an update to server /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb0c40000] DEBUG - [com.plexapp.system] Sending command over HTTP (GET): /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb0eca000] DEBUG - Notifying the system bundle an update to server /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb08a1000] DEBUG - TXT record updated: Maltes MacBook Air<br />
Oct 28, 2012 15:38:35 [0xb0eca000] DEBUG - [com.plexapp.system] Sending command over HTTP (GET): /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb0f4c000] DEBUG - Notifying the system bundle an update to server /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb08a1000] DEBUG - TXT record updated: Maltes MacBook Air<br />
Oct 28, 2012 15:38:35 [0xb0eca000] DEBUG - HTTP requesting to: http://127.0.0.1:55651/system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb0c40000] DEBUG - HTTP requesting to: http://127.0.0.1:55651/system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb0fce000] DEBUG - Notifying the system bundle an update to server /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb0fce000] DEBUG - [com.plexapp.system] Sending command over HTTP (GET): /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb08a1000] DEBUG - TXT record updated: Maltes MacBook Air<br />
Oct 28, 2012 15:38:35 [0xb0f4c000] DEBUG - [com.plexapp.system] Sending command over HTTP (GET): /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb0fce000] DEBUG - HTTP requesting to: http://127.0.0.1:55651/system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb0f4c000] DEBUG - HTTP requesting to: http://127.0.0.1:55651/system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb1050000] DEBUG - Notifying the system bundle an update to server /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb1050000] DEBUG - [com.plexapp.system] Sending command over HTTP (GET): /system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb1050000] DEBUG - HTTP requesting to: http://127.0.0.1:55651/system/notify/serverUpdated?host=Maltes-MacBook-Air.local.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /servers [127.0.0.1:63600] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000025 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /servers [127.0.0.1:63601] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000018 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /servers [127.0.0.1:63602] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000020 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /servers [127.0.0.1:63603] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000063 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb1154000] DEBUG - Request: GET /servers [127.0.0.1:63604] (2 live)<br />
Oct 28, 2012 15:38:35 [0xb1154000] DEBUG - It took 0.000024 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /library/sections [192.168.1.53:63605] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000407 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /library/sections [192.168.1.53:63606] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000397 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /library/sections [192.168.1.53:63607] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000313 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /library/sections [192.168.1.53:63608] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000397 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /library/sections [192.168.1.53:63609] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000403 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /channels/all [192.168.1.53:63610] (2 live)<br />
Oct 28, 2012 15:38:35 [0xb1154000] DEBUG - Request: GET /channels/all [192.168.1.53:63611] (2 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000047 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb1154000] DEBUG - It took 0.000022 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb1154000] DEBUG - Request: GET /channels/all [192.168.1.53:63612] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb1154000] DEBUG - It took 0.000032 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /channels/all [192.168.1.53:63613] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000034 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - Request: GET /channels/all [192.168.1.53:63614] (1 live)<br />
Oct 28, 2012 15:38:35 [0xb10d2000] DEBUG - It took 0.000027 sec to serialize a list with 1 elements.<br />
Oct 28, 2012 15:38:35 [0xb0f4c000] DEBUG - [com.plexapp.system] HTTP reply status 200, with 0 bytes of content.



"Maltes Macbook Air" is my macbook with the plex media server installed.

It seems that pyplex started correctly as you said but in my ios there is still no client. Maybe you find something wrong in my log :) I keep trying to find the problem :)


It seems like your plex server thinks the rs-pi is another server.

here's my log when i start the plex client:

<br />
<br />
Oct 28, 2012 15:48:06 [0xf43adb90] DEBUG - Avahi: New service 'Raspberry Plex' of type '_plexclient._tcp' in domain 'local'<br />
Oct 28, 2012 15:48:06 [0xf43adb90] DEBUG - Avahi: Resolved service 'Raspberry Plex' of type '_plexclient._tcp' in domain 'local' (machine=, version= updated=0)<br />
Oct 28, 2012 15:48:06 [0xf43adb90] DEBUG - Avahi: This was a new service Raspberry Plex<br />
Oct 28, 2012 15:48:06 [0xf43adb90] DEBUG - Avahi: Adding service Plex @ TARDIS<br />
Oct 28, 2012 15:48:06 [0xf43adb90] DEBUG - Avahi ~ change of state for entry group to 0<br />
Oct 28, 2012 15:48:06 [0xf43adb90] DEBUG - Avahi ~ change of state for entry group to 1<br />
Oct 28, 2012 15:48:07 [0xf43adb90] DEBUG - Avahi ~ change of state for entry group to 2<br />
Oct 28, 2012 15:48:07 [0xf43adb90] DEBUG - Avahi: Service 'Plex @ TARDIS' successfully established.<br />




Just to be clear, you do start the script with the command python pyplex.py 3000 ?


Hehe, yes :)

I will see if maybe something (program or something else) sends the wrong data, so he starts as a server.


That's good!

Have you changed any code? I think the __init__ of the ZeroconfService class needs to contain this:

def __init__(self, name, port, stype="_plexclient._tcp",<br />
                 domain="", host="", text=""):<br />



where the port is the port you give up on start of the script and the type (which you find back in my log files) tells the server it's a client.

but this is all guessing here, that part of the code was written by area so he might know more about it than me.


No I didn't change anything. Maybe Avahi is not working correctly? In your log you have DEBUG - AVAHI as prefix at my log there is only DEBUG. I will try to reinstall avahi.


let me know it it helps. Also, what is the version of your server?


Do you mean plex media server? Version: 0.9.6.9.240-8fd9c6a


Thats the latest version, so it's not plex. Have you installed avahi on the machine where plex server is running on?


No, is this required? I updated and reinstalled avahi - didn't help.


if the server is running on linux i think its required. Don't know for sure. On the download page for linux distros it says :
Tips

• For Bonjour discoverability, install and run Avahi.

so i guess it's required.