diff --git a/plexpy/activity_processor.py b/plexpy/activity_processor.py index 61e91426..36972480 100644 --- a/plexpy/activity_processor.py +++ b/plexpy/activity_processor.py @@ -466,4 +466,8 @@ class ActivityProcessor(object): 'FROM sessions ' 'WHERE user_id = ? %s' % ip, [user_id]) - return sessions \ No newline at end of file + return sessions + + def set_temp_stopped(self): + stopped_time = int(time.time()) + monitor_db.action('UPDATE sessions SET stopped = ?', [stopped_time]) \ No newline at end of file diff --git a/plexpy/web_socket.py b/plexpy/web_socket.py index 35458f2b..b758387a 100644 --- a/plexpy/web_socket.py +++ b/plexpy/web_socket.py @@ -24,6 +24,7 @@ import websocket import plexpy import activity_handler import activity_pinger +import activity_processor import logger name = 'websocket' @@ -38,6 +39,10 @@ def start_thread(): threading.Thread(target=run).start() +def on_disconnect(): + activity_processor.ActivityProcessor().set_temp_stopped() + + def reconnect(): global ws_reconnect ws_reconnect = True @@ -126,6 +131,7 @@ def run(): logger.info(u"PlexPy WebSocket :: Unable to get an internal response from the server, Plex server is down.") plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intdown'}) plexpy.PLEX_SERVER_UP = False + on_disconnect() plexpy.initialize_scheduler()