/status/sessions endpoint update
https://forums.plex.tv/discussion/comment/1497543/#Comment_1497543 (Serialization) /status/sessions endpoint for playbacks with multiple Media elements wasn't serialized to JSON correctly (#7344)
This commit is contained in:
parent
34e7307504
commit
3d2a6524a2
@ -1,5 +1,5 @@
|
|||||||
'''
|
'''
|
||||||
kill_transcode function from https://gist.github.com/Hellowlol/ee47b6534410b1880e19
|
fetch function from https://gist.github.com/Hellowlol/ee47b6534410b1880e19
|
||||||
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
|
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
|
||||||
[X] Notify on pause
|
[X] Notify on pause
|
||||||
|
|
||||||
@ -82,16 +82,17 @@ def kill_stream(sessionId, message, xtime, ntime, user, title, sessionKey):
|
|||||||
response = fetch('status/sessions')
|
response = fetch('status/sessions')
|
||||||
|
|
||||||
if response['MediaContainer']['Video']:
|
if response['MediaContainer']['Video']:
|
||||||
for a in response['MediaContainer']['Video']:
|
for video in response['MediaContainer']['Video']:
|
||||||
if a['sessionKey'] == sessionKey:
|
part = video['Media'][0]['Part'][0]
|
||||||
if xtime == ntime and a['Player']['state'] == 'paused' and a['Media']['Part']['decision'] == 'transcode':
|
if video['sessionKey'] == sessionKey:
|
||||||
|
if xtime == ntime and video['Player']['state'] == 'paused' and part['decision'] == 'transcode':
|
||||||
sys.stdout.write("Killing {user}'s paused stream of {title}".format(user=user, title=title))
|
sys.stdout.write("Killing {user}'s paused stream of {title}".format(user=user, title=title))
|
||||||
requests.get('http://{}:{}/status/sessions/terminate'.format(PLEX_HOST, PLEX_PORT),
|
requests.get('http://{}:{}/status/sessions/terminate'.format(PLEX_HOST, PLEX_PORT),
|
||||||
headers=headers, params=params)
|
headers=headers, params=params)
|
||||||
return ntime
|
return ntime
|
||||||
elif a['Player']['state'] in ('playing', 'buffering'):
|
elif video['Player']['state'] in ('playing', 'buffering'):
|
||||||
sys.stdout.write("{user}'s stream of {title} is now {state}".
|
sys.stdout.write("{user}'s stream of {title} is now {state}".
|
||||||
format(user=user, title=title, state=a['Player']['state']))
|
format(user=user, title=title, state=video['Player']['state']))
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return xtime
|
return xtime
|
||||||
@ -104,8 +105,7 @@ def find_sessionID(response):
|
|||||||
|
|
||||||
sessions = []
|
sessions = []
|
||||||
for s in response['MediaContainer']['Video']:
|
for s in response['MediaContainer']['Video']:
|
||||||
if s['sessionKey'] == sys.argv[1] and s['Player']['state'] == 'paused' \
|
if s['sessionKey'] == sys.argv[1] and s['Player']['state'] == 'paused' and s['Media']['Part']['decision'] == 'transcode':
|
||||||
and s['Media']['Part']['decision'] == 'transcode':
|
|
||||||
sess_id = s['Session']['id']
|
sess_id = s['Session']['id']
|
||||||
user = s['User']['title']
|
user = s['User']['title']
|
||||||
sess_key = sys.argv[1]
|
sess_key = sys.argv[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user