From cf55f239fb57280d8d71aa02ed6052478c7ef842 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 17 Jul 2015 23:42:25 +0200 Subject: [PATCH] PHT sometimes not logging IP. This fix may help. --- plexpy/monitor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plexpy/monitor.py b/plexpy/monitor.py index f074ba49..7830ea42 100644 --- a/plexpy/monitor.py +++ b/plexpy/monitor.py @@ -317,13 +317,14 @@ class MonitorProcessing(object): logger.debug(u"PlexPy Monitor :: Requesting log lines...") log_lines = log_reader.get_log_tail(window=5000, parsed=False) - rating_key_line = 'metadata%2F' + rating_key + rating_key_line = 'ratingKey=' + rating_key + rating_key_line_2 = 'metadata%2F' + rating_key machine_id_line = 'session=' + machine_id for line in reversed(log_lines): # We're good if we find a line with both machine id and rating key # This is usually when there is a transcode session - if machine_id_line in line and rating_key_line in line: + if machine_id_line in line and (rating_key_line in line or rating_key_line_2 in line): # Currently only checking for ipv4 addresses ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}', line) if ipv4: @@ -344,7 +345,7 @@ class MonitorProcessing(object): log_lines = log_reader.get_log_tail(window=5000, parsed=False) for line in reversed(log_lines): - if 'GET /:/timeline' in line and rating_key_line in line: + if 'GET /:/timeline' in line and (rating_key_line in line or rating_key_line_2 in line): # Currently only checking for ipv4 addresses # This method can return the wrong IP address if more than one user # starts watching the same media item around the same time.