Skip to content

Commit

Permalink
Update README example for new use
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlawren committed Mar 25, 2021
1 parent 394956f commit 896b448
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ Async library to react to events issued over Plex websockets.
## Example use
```python
import asyncio
import logging
from plexapi.server import PlexServer
from plexwebsocket import PlexWebsocket
from plexwebsocket import PlexWebsocket, SIGNAL_CONNECTION_STATE

logging.basicConfig(level=logging.DEBUG)

baseurl = 'http://<PLEX_SERVER_IP>:32400'
token = '<YOUR_TOKEN_HERE>'
plex = PlexServer(baseurl, token)

def print_info(signal, data, error):
if signal == "data":
print(f"Data: {data}")
elif signal == "state":
def print_info(msgtype, data, error):
if msgtype == SIGNAL_CONNECTION_STATE:
print(f"State: {data} / Error: {error}")
else:
print(f"Data: {data}")

async def main():
ws = PlexWebsocket(plex, print_info)
ws = PlexWebsocket(plex, print_info, subscriptions=["playing", "state"])

This comment has been minimized.

Copy link
@glensc

glensc Jan 11, 2023

I think it's "status" not "state", at least it was so, when I saved down list of events in my project:

This comment has been minimized.

Copy link
@jjlawren

jjlawren Jan 30, 2023

Author Owner

Yep, you're right. Fixed the typo. Thanks for pointing it out.

This comment has been minimized.

Copy link
@glensc
await ws.listen()

if __name__ == '__main__':
Expand Down

0 comments on commit 896b448

Please sign in to comment.