mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 06:04:15 +00:00
Add alertlistener example
This commit is contained in:
parent
0a6655fddd
commit
874281828a
1 changed files with 22 additions and 0 deletions
22
tools/plex-alertlistener.py
Executable file
22
tools/plex-alertlistener.py
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Listen to plex alerts and print them to the console.
|
||||
Because we're using print as a function, example only works in Python3.
|
||||
"""
|
||||
import time
|
||||
from plexapi.server import PlexServer
|
||||
|
||||
|
||||
def _print(msg):
|
||||
print(msg)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
plex = PlexServer()
|
||||
listener = plex.startAlertListener(_print)
|
||||
while True:
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
listener.stop()
|
Loading…
Reference in a new issue