Plex Status - Video, Audio, Photo, Play Progress
Moderator: leecollings
-
- 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
Script has been updated, please update.
Several Changes:
- User Variables were updated every iteration causing excessive triggering of events when used. This has been fixed to only update on state change.
- Reduced default plex_ViewOffsetTimeout value from 15 to 10. Stopped State should get detected more quickly
- Added an error counter. Plex Server is now considered offline when three consecutive requests timeout or fail.
Several Changes:
- User Variables were updated every iteration causing excessive triggering of events when used. This has been fixed to only update on state change.
- Reduced default plex_ViewOffsetTimeout value from 15 to 10. Stopped State should get detected more quickly
- Added an error counter. Plex Server is now considered offline when three consecutive requests timeout or fail.
- nayr
- Posts: 354
- Joined: Tuesday 11 November 2014 18:42
- Target OS: Linux
- Domoticz version: github
- Location: Denver, CO - USA
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
getting 401 Unauthorized, I have 192.168.0.0/255.255.0.0 in my list of networks without auth.. seems to be ignoring it.
*edit*
Fixed it, signed the server out of myplex and restarted service.. now it works.
*edit*
Fixed it, signed the server out of myplex and restarted service.. now it works.
Last edited by nayr on Monday 28 December 2015 5:12, edited 1 time in total.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
- nayr
- Posts: 354
- Joined: Tuesday 11 November 2014 18:42
- Target OS: Linux
- Domoticz version: github
- Location: Denver, CO - USA
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
I am getting alot of stoping and starting, when in fact I know its not
changed the default of ViewOffsetTimeout back to 15 and that seemed to alleviate it, seems to be hitting a race condition.
also appears that plexStatus_IDX does nothing
edit, I also encounter some escaping issues, this may be my version of domo.. its not the latest
Code: Select all
Episode Playing: Octonauts - The Humphead Parrotfish (0:03:38/0:10:00)
Episode Playing: Octonauts - The Humphead Parrotfish (0:03:53/0:10:00)
Episode Stopped: Octonauts - The Humphead Parrotfish (0:03:53/0:10:00)
Episode Playing: Octonauts - The Humphead Parrotfish (0:04:09/0:10:00)
Episode Stopped: Octonauts - The Humphead Parrotfish (0:04:09/0:10:00)
Episode Playing: Octonauts - The Humphead Parrotfish (0:04:24/0:10:00)
Episode Playing: Octonauts - The Humphead Parrotfish (0:04:40/0:10:00)
Episode Stopped: Octonauts - The Humphead Parrotfish (0:04:40/0:10:00)
Episode Playing: Octonauts - The Humphead Parrotfish (0:04:55/0:10:00)
Episode Playing: Octonauts - The Humphead Parrotfish (0:05:11/0:10:00)
Episode Stopped: Octonauts - The Humphead Parrotfish (0:05:11/0:10:00)
Episode Playing: Octonauts - The Humphead Parrotfish (0:05:26/0:10:00)
Episode Playing: Octonauts - The Humphead Parrotfish (0:05:42/0:10:00)
also appears that plexStatus_IDX does nothing
edit, I also encounter some escaping issues, this may be my version of domo.. its not the latest
Code: Select all
2015-12-27 22:26:15.315 Error: SQL Query("UPDATE DeviceStatus SET SignalLevel=12, BatteryLevel=255, nValue=0, sValue='Playing Episode: Oliver Stone's Untold History of the United States - Johnson, Nixon & Vietnam: Reversal of Fortune (0:01:48/0:57:57)', LastUpdate='2015-12-27 22:26:15' WHERE (ID = 114)") : near "s": syntax error
Last edited by nayr on Monday 28 December 2015 7:15, edited 1 time in total.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
-
- 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
Yup Plexstatus_Idx is a remnant of an early version. It does nothing anymore. I'll change back the Viewoffsettimeout back to 15. Should have realised 10 is to tight. It's equal to the plex session update interval.
I've not seen the escaping issue myself, but seems to be an domoticz issue. It should escape on it's own but it's clearly not. Quite the security issue, allowing sql injections through the api. I'll test it with the latest domoticz version when I'm back from work.
I've not seen the escaping issue myself, but seems to be an domoticz issue. It should escape on it's own but it's clearly not. Quite the security issue, allowing sql injections through the api. I'll test it with the latest domoticz version when I'm back from work.
- nayr
- Posts: 354
- Joined: Tuesday 11 November 2014 18:42
- Target OS: Linux
- Domoticz version: github
- Location: Denver, CO - USA
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
escaping issue was fixed with updating, now to get regressions fixed.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Re: Plex Status - Video, Audio, Photo, Play Progress
Works great, but it crashes with the Plex Trailer Preview option. First trailer = ok. After trailer change it crashes. When loading a movie the script runs fine. Has it todo with the movie time calculation?
P.s: on my ubuntu machine i had some problems starting this script with crontab and the crontab @reboot option. So i just put the script in my /etc/rc.local file. Yes, its a quick 'nd dirty way but it works.
Update:
Short demo's running fine
Movies running fine
Crashes on trailers (Plex Feature)
Update after some more tests:
From a normal movie to a trailer -> ok. After loading second trailer it crashes. After loading normal movie again, the scripts continues to work.
P.s: on my ubuntu machine i had some problems starting this script with crontab and the crontab @reboot option. So i just put the script in my /etc/rc.local file. Yes, its a quick 'nd dirty way but it works.
Update:
Short demo's running fine
Movies running fine
Crashes on trailers (Plex Feature)
Update after some more tests:
From a normal movie to a trailer -> ok. After loading second trailer it crashes. After loading normal movie again, the scripts continues to work.
Code: Select all
Traceback (most recent call last):
File "./plex.py", line 101, in <module>
durTotalSeconds = long(long(videoduration) / 1000)
TypeError: long() argument must be a string or a number, not 'NoneType'
None
Traceback (most recent call last):
File "./plex.py", line 346, in <module>
ErrorCount+=1
NameError: name 'ErrorCount' is not defined
- nayr
- Posts: 354
- Joined: Tuesday 11 November 2014 18:42
- Target OS: Linux
- Domoticz version: github
- Location: Denver, CO - USA
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
try modifying this line:
it will check that videoduration is an integer before firing of those calculations, the next else statement looks like sets all the values to 0 if that's not a number.
I am thinking trailers are not giving you a correct videodurration, would have to show us what the XML of your plexserver is when you crash
Code: Select all
if plex_ShowPlayProgress and isinstance(videoduration, int):
I am thinking trailers are not giving you a correct videodurration, would have to show us what the XML of your plexserver is when you crash
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
-
- 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
Good catch, had not tested the script with trailers since i didn't have plex Pass.
Nayr suggestion should work. it will disable playprogress when it has invalid input
Since you got a NoneType Exception this should also just work just fine:
When the problem occurs again, please go to:
and tell us whats listed under 'duration'
Fixed the missing ErrorCount definition. Just add ErrorCount=0 at the top of the file. No idea why it was missing, all my local copies do have that line.
Nayr suggestion should work. it will disable playprogress when it has invalid input
Since you got a NoneType Exception this should also just work just fine:
Code: Select all
if plex_ShowPlayProgress and videoduration is not None:
Code: Select all
http://<PLEXURL>:32400/status/sessions
Fixed the missing ErrorCount definition. Just add ErrorCount=0 at the top of the file. No idea why it was missing, all my local copies do have that line.
Re: Plex Status - Video, Audio, Photo, Play Progress
I'll check the fix this afternoon. For now I quickly reproduced the situation and captured the XML output for your analysis.
Code: Select all
<MediaContainer size="1">
<Video addedAt="1453701678" contentRating="PG-13" extraType="1" guid="http://api.internetvideoarchive.com/2.0/DataService/VideoAssets(378429)?lang=en&bitrates=2500,1500,450" index="1" key="/library/metadata/3576" lastViewedAt="1453654209" originallyAvailableAt="2010-09-26" ratingKey="3576" sessionKey="1" summary="" thumb="/library/metadata/3576/thumb/1453701678" title="Ant-Man" type="clip" viewOffset="18022" year="2010">
<Media aspectRatio="1.78" bitrate="2500" container="mp4" height="1080" id="9255" premium="1" videoResolution="1080" width="1920">
<Part container="mp4" duration="149000" id="9260" key="/services/iva/assets/378429/video.mp4?bitrate=2500" optimizedForStreaming="1">
<Stream codec="h264" height="1080" id="19897" index="0" selected="1" streamType="1" width="1920"/>
<Stream codec="aac" id="19898" index="1" language="English" languageCode="eng" streamType="2"/>
</Part>
</Media>
<Media aspectRatio="1.78" bitrate="1500" container="mp4" height="720" id="9256" premium="1" videoResolution="720" width="1280">
<Part container="mp4" duration="149000" id="9261" key="/services/iva/assets/378429/video.mp4?bitrate=1500" optimizedForStreaming="1">
<Stream codec="h264" height="720" id="19899" index="0" selected="1" streamType="1" width="1280"/>
<Stream codec="aac" id="19900" index="1" language="English" languageCode="eng" streamType="2"/>
</Part>
</Media>
<Media aspectRatio="1.33" bitrate="450" container="mp4" height="480" id="9257" premium="1" videoResolution="480" width="640">
<Part container="mp4" duration="149000" id="9262" key="/services/iva/assets/378429/video.mp4?bitrate=450" optimizedForStreaming="1">
<Stream codec="h264" height="480" id="19901" index="0" selected="1" streamType="1" width="640"/>
<Stream codec="aac" id="19902" index="1" language="English" languageCode="eng" streamType="2"/>
</Part>
</Media>
<User id="1" thumb="https://plex.tv/users/e9bc26ab62648057/avatar" title="maxbierlee"/>
<Player address="10.1.1.42" machineIdentifier="253ce4af-488f-4dd2-9d59-dd6229db5073" platform="Chrome" product="Plex Web" state="paused" title="Plex Web (Chrome)"/>
</Video>
</MediaContainer>
-
- 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
Thanks for the information, this helps. It seems some clips produce the duration attribute but not the viewoffset attribute. Others have the ViewOffset but not the duration.
The fix should be enough, PlayProgress won't be shown but that isn't really important anyway
Has anyone else noticed the issue that the script sometimes thinks that there is no media playing while there actually is? I've noticed this ever since i starting dimming my lights based on the user variables.
Pretty annoying having the lights undim for 10 seconds during a movie. Can anyone spot the problem in the code? I looked at it many times but i've yet to find the cause.
The fix should be enough, PlayProgress won't be shown but that isn't really important anyway
Has anyone else noticed the issue that the script sometimes thinks that there is no media playing while there actually is? I've noticed this ever since i starting dimming my lights based on the user variables.
Pretty annoying having the lights undim for 10 seconds during a movie. Can anyone spot the problem in the code? I looked at it many times but i've yet to find the cause.
-
- Posts: 18
- Joined: Thursday 11 February 2016 8:37
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
Thanks for this great script.
It works fine BUT only for english title.
When I try to read movie with accents (I'm french), I get an error.
It works fine BUT only for english title.
When I try to read movie with accents (I'm french), I get an error.
How to fix it ?u'\xe9'
Traceback (most recent call last):
File "/volume1/@appstore/domoticz/var/scripts/plex3.py", line 164, in <module>
PlayString = urllib.quote(PlayString)
File "/usr/local/lib/python2.7/urllib.py", line 1294, in quote
return ''.join(map(quoter, s)
-
- 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
Thanks for the feedback.
It's Probably an issue with escaping. I came across same thing. I'll post an updated script this evening when i get back from work, it may fix the problem.
It's Probably an issue with escaping. I came across same thing. I'll post an updated script this evening when i get back from work, it may fix the problem.
-
- Posts: 18
- Joined: Thursday 11 February 2016 8:37
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
Thanks from France for this fast reply
Just another thing, how can I translate in french the message in Domoticz "Not Playing Media" ou "Playing Video" ?
Just another thing, how can I translate in french the message in Domoticz "Not Playing Media" ou "Playing Video" ?
-
- 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
"No media playing" is a string constant in the script. You can easily replace it yourself.
Playing Video is a bit more tricky for a novice. "Video" & "Stopped" is a constant and can be replaced the same way as "no media playing". It's prefixes however are retrieved directly from the Plex API call response which is fixed to english
Therefore it's best to add several string replace statements just before the domoticz URL is built in the script. You can google 'python string replace' to see how it's done.
Replace the following text which your own translation:
- Playing
- Paused
- Buffering
Playing Video is a bit more tricky for a novice. "Video" & "Stopped" is a constant and can be replaced the same way as "no media playing". It's prefixes however are retrieved directly from the Plex API call response which is fixed to english
Therefore it's best to add several string replace statements just before the domoticz URL is built in the script. You can google 'python string replace' to see how it's done.
Replace the following text which your own translation:
- Playing
- Paused
- Buffering
-
- Posts: 18
- Joined: Thursday 11 February 2016 8:37
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
Thanks but when I search for "No media playing", the result is negativ.
If I replace a string, must the script be stopped and relaunched or no ?
If it must be stopped, how can I stop it on my synology ?
If I replace a string, must the script be stopped and relaunched or no ?
If it must be stopped, how can I stop it on my synology ?
-
- 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
That's because the string has been url encoded, you should be able to find:
No%20Media%20Playing
Yes the script must be restarted. if you followed the instructions in the first post the script will only be started at startup. So the easiest way is to just reboot the system.
I'll get back to you for the escaping problem, was to tired yesterday to do anything.
No%20Media%20Playing
Yes the script must be restarted. if you followed the instructions in the first post the script will only be started at startup. So the easiest way is to just reboot the system.
I'll get back to you for the escaping problem, was to tired yesterday to do anything.
-
- Posts: 18
- Joined: Thursday 11 February 2016 8:37
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
Thanks for all.
I will wait for escaping problem.
I will wait for escaping problem.
-
- 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
The script has been updated. Strings should now be properly encoded as utf-8
Script with no longer crash when there are accents in the title.
Quick test:
Script with no longer crash when there are accents in the title.
Quick test:
-
- Posts: 18
- Joined: Thursday 11 February 2016 8:37
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
Thanks
I will try
I will try
-
- Posts: 18
- Joined: Thursday 11 February 2016 8:37
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Plex Status - Video, Audio, Photo, Play Progress
I'm sorry but it doesn't work
I get
I get
Episode Paused: X-Files : Aux frontières du réel - Nouvelle génération - 1ère partie (0:00:18/0:44:40)
IDLE
u'\xe8'
Traceback (most recent call last):
File "plex2.py", line 164, in <module>
PlayString = urllib.quote(PlayString)
File "/usr/local/lib/python2.7/urllib.py", line 1294, in quote
return ''.join(map(quoter, s))
KeyError: u'\xe8'
Who is online
Users browsing this forum: No registered users and 0 guests