From b87eb68bdd03d81766068b64f1449c359f52cf3d Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Tue, 27 Feb 2018 20:03:31 -0800 Subject: [PATCH] Identify if a stream is using Plex Relay --- API.md | 1 + .../default/current_activity_instance.html | 24 +++++++++++-------- plexpy/pmsconnect.py | 4 ++++ plexpy/webserve.py | 1 + 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/API.md b/API.md index d78ec99c..2ff5fb9d 100644 --- a/API.md +++ b/API.md @@ -401,6 +401,7 @@ Returns: "quality_profile": "Original", "rating": "7.8", "rating_key": "153037", + "relay": 0, "section_id": "2", "session_id": "helf15l3rxgw01xxe0jf3l3d", "session_key": "27", diff --git a/data/interfaces/default/current_activity_instance.html b/data/interfaces/default/current_activity_instance.html index 61467084..1aa409d9 100644 --- a/data/interfaces/default/current_activity_instance.html +++ b/data/interfaces/default/current_activity_instance.html @@ -279,16 +279,20 @@ DOCUMENTATION :: END ${data['location'].upper()}: % if data['ip_address'] != 'N/A': ${data['ip_address']} - - - - + % if data['relay']: + + % else: + + + + + % endif % else: N/A % endif diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index df9a5cb3..c84b62d0 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1404,6 +1404,10 @@ class PmsConnect(object): 'location': 'wan' if player_details['local'] == '0' else 'lan' } + # Check if using Plex Relay + session_details['relay'] = int(session_details['location'] != 'lan' + and player_details['ip_address_public'] == '127.0.0.1') + # Get the transcode details if session.getElementsByTagName('TranscodeSession'): transcode_info = session.getElementsByTagName('TranscodeSession')[0] diff --git a/plexpy/webserve.py b/plexpy/webserve.py index d2405da5..a6a4182e 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -4706,6 +4706,7 @@ class WebInterface(object): "quality_profile": "Original", "rating": "7.8", "rating_key": "153037", + "relay": 0, "section_id": "2", "session_id": "helf15l3rxgw01xxe0jf3l3d", "session_key": "27",