From d79d5d5b39fcc6b20d1b9199f2a3532978daf3ee Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Wed, 11 Nov 2015 09:16:28 -0800 Subject: [PATCH] Better IP address handling for current activity --- data/interfaces/default/current_activity.html | 5 +++++ plexpy/datafactory.py | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/data/interfaces/default/current_activity.html b/data/interfaces/default/current_activity.html index af8ae85b..ad78ee22 100644 --- a/data/interfaces/default/current_activity.html +++ b/data/interfaces/default/current_activity.html @@ -32,6 +32,7 @@ user_thumb Returns the profile picture of the user owning the s state Returns the state of the current session. Either 'playing', 'paused' or 'buffering'. title Returns the name of the episode, movie or music track. year Returns the year of the episode, movie, or clip. +ip_address Returns the ip address of the stream. player Returns the name of the platform used to play the stream. platform Returns the type of platform used to play the stream. throttled Returns true if the transcode session is throttled. @@ -192,7 +193,11 @@ DOCUMENTATION :: END % if a['media_type'] != 'photo':
+ % if a['ip_address']: IP: ${a['ip_address']} + % else: + IP: N/A + % endif
${a['view_offset']}/${a['duration']} diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 28d09ebb..38c4e5ce 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -1004,8 +1004,7 @@ class DataFactory(object): monitor_db = database.MonitorDatabase() if session_key: - query = 'SELECT CASE WHEN ip_address IS NULL THEN "N/A" ELSE ip_address END ' \ - 'FROM sessions WHERE session_key = %d' % int(session_key) + query = 'SELECT ip_address FROM sessions WHERE session_key = %d' % int(session_key) result = monitor_db.select(query) else: return None