mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-25 21:20:18 +00:00
add websocket to requirements.txt
We just just install all the packages we need
This commit is contained in:
parent
cbde4787cc
commit
351fe3565d
2 changed files with 6 additions and 11 deletions
|
@ -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):
|
||||
|
|
|
@ -3,3 +3,4 @@
|
|||
# pip install -r requirments.txt
|
||||
#---------------------------------------------------------
|
||||
requests
|
||||
websocket
|
Loading…
Reference in a new issue