diff --git a/plexapi/alert.py b/plexapi/alert.py index 0c127330..2a160629 100644 --- a/plexapi/alert.py +++ b/plexapi/alert.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- import json import threading + +import websocket + from plexapi import log -from plexapi.exceptions import Unsupported class AlertListener(threading.Thread): @@ -12,9 +14,6 @@ class AlertListener(threading.Thread): alerts you must call .start() on the object once it's created. When calling `PlexServer.startAlertListener()`, the thread will be started for you. - In order to use this feature, you must have websocket-client installed in your Python path. - This can be installed vis pip `pip install websocket-client`. - Parameters: server (:class:`~plexapi.server.PlexServer`): PlexServer this listener is connected to. callback (func): Callback function to call on recieved messages. The callback function @@ -30,17 +29,12 @@ class AlertListener(threading.Thread): super(AlertListener, self).__init__() def run(self): - # try importing websocket-client package - try: - import websocket - except: - raise Unsupported('Websocket-client package is required to use this feature.') # create the websocket connection url = self._server.url(self.key).replace('http', 'ws') log.info('Starting AlertListener: %s', url) self._ws = websocket.WebSocketApp(url, - on_message=self._onMessage, - on_error=self._onError) + on_message=self._onMessage, + on_error=self._onError) self._ws.run_forever() def stop(self): diff --git a/requirements.txt b/requirements.txt index 36a5315d..297e3001 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ # pip install -r requirments.txt #--------------------------------------------------------- requests +websocket \ No newline at end of file