diff --git a/plexpy/activity_processor.py b/plexpy/activity_processor.py index fda00ac1..df9131cb 100644 --- a/plexpy/activity_processor.py +++ b/plexpy/activity_processor.py @@ -39,7 +39,6 @@ class ActivityProcessor(object): 'parent_title': session['parent_title'], 'grandparent_title': session['grandparent_title'], 'friendly_name': session['friendly_name'], - 'ip_address': session['ip_address'], 'player': session['player'], 'platform': session['platform'], 'parent_rating_key': session['parent_rating_key'], @@ -78,20 +77,19 @@ class ActivityProcessor(object): threading.Thread(target=notification_handler.notify, kwargs=dict(stream_data=values, notify_action='play')).start() + # If it's our first write then time stamp it. started = int(time.time()) timestamp = {'started': started} + self.db.upsert('sessions', timestamp, keys) + ip_address = {'ip_address': session['ip_address']} # Try and grab IP address from logs (fallback if not on PMS 0.9.14 and above) if not session['ip_address']: if plexpy.CONFIG.IP_LOGGING_ENABLE and plexpy.CONFIG.PMS_LOGS_FOLDER: ip_address = self.find_session_ip(rating_key=session['rating_key'], machine_id=session['machine_id']) - timestamp.update({'ip_address': ip_address}) - else: - timestamp.update({'ip_address': None}) - - # If it's our first write then time stamp it. - self.db.upsert('sessions', timestamp, keys) + ip_address = {'ip_address': ip_address} + self.db.upsert('sessions', ip_address, keys) def write_session_history(self, session=None, import_metadata=None, is_import=False, import_ignore_interval=0): from plexpy import users