Plex Status - Video, Audio, Photo, Play Progress

Python and python framework

Moderator: leecollings

cattoo
Posts: 60
Joined: Sunday 20 September 2015 17:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3072
Location: Sweden
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by cattoo »

Well, I put the PID part back in the script. And did a couple of reboots. Now its working on some of the flex players. Will test more when I get home.
racquemis
Posts: 73
Joined: Monday 02 November 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by racquemis »

The issue was probably due to timeouts from excessive http get requests due the misconfigured script.

Keep me posted ;)
chrisfraser05
Posts: 32
Joined: Sunday 08 January 2017 18:59
Target OS: Windows
Domoticz version:
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by chrisfraser05 »

does anyone have any info on how to run this on windows?

I'm struggling to find info :(
racquemis
Posts: 73
Joined: Monday 02 November 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by racquemis »

If you want to run the script from Windows first install python 2.7 on your system.

Next create a new bat file and input the following:

Code: Select all

C:\python27\python.exe c:\<plex script directory>\plex.py

Save the file somewhere that makes sense, e.g. same place as the script file.
Now create a shortcut for the bat file and place it in the startup folder ( %AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup) to make it the script autorun on login.
chrisfraser05
Posts: 32
Joined: Sunday 08 January 2017 18:59
Target OS: Windows
Domoticz version:
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by chrisfraser05 »

As Simple as that?

Thanks very much for the assistance!
racquemis
Posts: 73
Joined: Monday 02 November 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by racquemis »

Yes, but do you get a command prompt type window on your desktop
If you want to run the script invisibly rename python.exe in the bat file to pythonw.exe.
chrisfraser05
Posts: 32
Joined: Sunday 08 January 2017 18:59
Target OS: Windows
Domoticz version:
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by chrisfraser05 »

Thanks guys

Got this running brilliantly after a bit of messing about!

As always the help on here is brilliant!


I'm going to have to try and figure out how to use it to trigger some automation now :0
chrisfraser05
Posts: 32
Joined: Sunday 08 January 2017 18:59
Target OS: Windows
Domoticz version:
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by chrisfraser05 »

Has anyone gotten this to see what Chromecast is playing?

I can't get it to work, but then I'm struggling to find out what plex names the device.

None of the devices show their name in the session/status page, and under devices all three of my Chromecast are known as Chromecast, which doesn't work.
cattoo
Posts: 60
Joined: Sunday 20 September 2015 17:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3072
Location: Sweden
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by cattoo »

I think that you should be checking that device that you are casting from.
racquemis
Posts: 73
Joined: Monday 02 November 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by racquemis »

The names you should be using are the same names that appear under to status sessions page but also the names under now playing in Plex Web. But if it doesn't appear under sessions while playing something over the chromecast there is nothing I can do.

About the chromecast: with the chromecast app on Android, used to configure and connect the chromecast to your wifi network, you also have the ability to chance the device name. Google for the info on how to do it.
kllngtme
Posts: 47
Joined: Tuesday 14 June 2016 16:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: East Coast, USA
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by kllngtme »

So I'm trying to figure out how to make a blockly script with this to turn off a light if something is playing. How do I do this with a text field in Domoticz? Any info to start would be great now that I got this Plex script working with Domoticz..
racquemis
Posts: 73
Joined: Monday 02 November 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by racquemis »

The script automatically creates a user variable for each for the configured plex clients. It's value indicated the playback status. It in the documentation in the first post. These user variables can be used directly in blockly
rathmannm
Posts: 15
Joined: Sunday 10 January 2016 18:56
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by rathmannm »

Hi,

I can't seem to get this to work. When I run plex.py manually I get the following error:

Traceback (most recent call last):
File "./plex.py", line 119, in <module>
test = urllib2.urlopen(requestURL,timeout = 5).read()
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 407, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 520, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 445, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized

I have Plex Pass so I have added the
plexToken = 'xxxxxxxxxxxxxx'

In my Plex server network settings under "List of IP addresses and networks that are allowed without auth" I have also
maintained the IP address where I am running the plex.py from.

Any idea what I am missing?

Thanks,
Manuel
racquemis
Posts: 73
Joined: Monday 02 November 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by racquemis »

First thing in troubleshooting your issue is to navigate to the URL the scripts build manually with your browser.

http://<IP>:32400/status/sessions?X-Plex-Token=<YOURTOKEN>
If you still get an unauthorized reponse from the URL then either the token is incorrect or Plex doesn't recognize the network/IP the command is issued from as being whitelisted.

Under "List of IP addresses and networks that are allowed without auth" in plex. Whitelist the gateway (not your IP) and subnet mask.
So if your on for example IP 192.168.2.5 with gateway address 192.168.2.254 enter the following: 192.168.2.254/255.255.255.0

This will whitelist all devices on the specified internal network from accessing the plex server.
Onkytonk
Posts: 14
Joined: Saturday 24 June 2017 2:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by Onkytonk »

rathmannm wrote:Hi,

I can't seem to get this to work. When I run plex.py manually I get the following error:

Traceback (most recent call last):
File "./plex.py", line 119, in <module>
test = urllib2.urlopen(requestURL,timeout = 5).read()
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 407, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 520, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 445, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized

I have Plex Pass so I have added the
plexToken = 'xxxxxxxxxxxxxx'

In my Plex server network settings under "List of IP addresses and networks that are allowed without auth" I have also
maintained the IP address where I am running the plex.py from.

Any idea what I am missing?

Thanks,
Manuel
I'm getting the very same error - Though between the errors, it is displaying whats playing! So something is working, but the error is preventing the information relaying to the domoticz text/variable.

I've whitelisted the IP/subnet into plex already but still not luck.

Any help please?

EDIT: Removed everything and started from scratch and got everything working!!

Now though, having issues with the variables not updating automatically unless I run the script manually.

Any help on this one please?
cattoo
Posts: 60
Joined: Sunday 20 September 2015 17:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3072
Location: Sweden
Contact:

Re: Plex Status - Video, Audio, Photo, Play Progress

Post by cattoo »

Onkytonk wrote: Saturday 01 July 2017 20:17
rathmannm wrote:Hi,

I can't seem to get this to work. When I run plex.py manually I get the following error:

Traceback (most recent call last):
File "./plex.py", line 119, in <module>
test = urllib2.urlopen(requestURL,timeout = 5).read()
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 407, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 520, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 445, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized

I have Plex Pass so I have added the
plexToken = 'xxxxxxxxxxxxxx'

In my Plex server network settings under "List of IP addresses and networks that are allowed without auth" I have also
maintained the IP address where I am running the plex.py from.

Any idea what I am missing?

Thanks,
Manuel
I'm getting the very same error - Though between the errors, it is displaying whats playing! So something is working, but the error is preventing the information relaying to the domoticz text/variable.

I've whitelisted the IP/subnet into plex already but still not luck.

Any help please?

EDIT: Removed everything and started from scratch and got everything working!!

Now though, having issues with the variables not updating automatically unless I run the script manually.

Any help on this one please?
You could see if the script is running top -U pi (or what user you are use)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest