diff --git a/PlexPy.py b/PlexPy.py index bcc17654..ac97d020 100755 --- a/PlexPy.py +++ b/PlexPy.py @@ -196,7 +196,7 @@ def main(): # Open connection for websocket try: - web_socket.start_thread() + web_socket.start_thread(startup=True) except: logger.warn(u"Websocket :: Unable to open connection.") plexpy.initialize_scheduler() diff --git a/plexpy/activity_pinger.py b/plexpy/activity_pinger.py index 1e3783d3..96ff3c36 100644 --- a/plexpy/activity_pinger.py +++ b/plexpy/activity_pinger.py @@ -328,7 +328,7 @@ def check_server_updates(): logger.info(u"Tautulli Monitor :: No PMS update available.") -def check_cloud_status(log=False): +def check_cloud_status(log=False, return_status=False): if log: logger.info(u"Tautulli Monitor :: Checking for Plex Cloud server status...") @@ -337,7 +337,11 @@ def check_cloud_status(log=False): if cloud_status: logger.info(u"Tautulli Monitor :: Plex Cloud server is active.") + if return_status: + return cloud_status check_server_response() else: if log: logger.info(u"Tautulli Monitor :: Plex Cloud server is sleeping.") + if return_status: + return cloud_status diff --git a/plexpy/web_socket.py b/plexpy/web_socket.py index a9613e40..6366ed43 100644 --- a/plexpy/web_socket.py +++ b/plexpy/web_socket.py @@ -32,7 +32,13 @@ opcode_data = (websocket.ABNF.OPCODE_TEXT, websocket.ABNF.OPCODE_BINARY) ws_reconnect = False -def start_thread(): +def start_thread(startup=False): + if startup and plexpy.CONFIG.PMS_IS_CLOUD and plexpy.PLEX_SERVER_UP is None: + plexpy.PLEX_SERVER_UP = activity_pinger.check_cloud_status(log=True, return_status=True) + if not plexpy.PLEX_SERVER_UP: + on_disconnect() + return + if plexpy.CONFIG.FIRST_RUN_COMPLETE: # Check for any existing sessions on start up activity_pinger.check_active_sessions(ws_request=True)