Skip to content

Commit

Permalink
Add plex alert listener tool script
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiRigal committed May 5, 2022
1 parent cc5e6bd commit a441355
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tools/plex_alert_listener.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import time
import json
import argparse
from datetime import datetime
from plexapi.server import PlexServer


def callback(message):
message["time"] = datetime.now().isoformat()
print(json.dumps(message))


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--plex_url", type=str, default="http://localhost:32400", help="Plex URL")
parser.add_argument("--plex_token", type=str, required=True, help="Plex Token")
args = parser.parse_args()

plex = PlexServer(args.plex_url, args.plex_token)

notifier = plex.startAlertListener(callback)

while notifier.is_alive():
time.sleep(1)
time.sleep(1)

0 comments on commit a441355

Please sign in to comment.