diff --git a/notify/notify_delay.py b/notify/notify_delay.py index db3c665..bd0eaf0 100644 --- a/notify/notify_delay.py +++ b/notify/notify_delay.py @@ -1,4 +1,4 @@ -''' +""" Delay Notification Agent message for concurrent streams Arguments passed from PlexPy @@ -12,22 +12,21 @@ PlexPy > Settings > Notification Agents > Scripts > Gear icon: User Concurrent Streams: notify_delay.py PlexPy Settings > Notification Agents > Scripts (Gear) > Script Timeout: 0 to disable or set to > 180 -''' +""" import requests import sys import argparse from time import sleep - ## EDIT THESE SETTINGS ## -PLEXPY_APIKEY = 'xxxxx' # Your PlexPy API key -PLEXPY_URL = 'http://localhost:8182/' # Your PlexPy URL +PLEXPY_APIKEY = '' # Your PlexPy API key +PLEXPY_URL = 'http://localhost:8181/' # Your PlexPy URL CONCURRENT_TOTAL = 2 TIMEOUT = 180 INTERVAL = 20 -AGENT_ID = 10 # Notification agent ID for PlexPy +NOTIFIER_ID = 10 # Notification notifier ID for PlexPy # Find Notification agent ID here: # https://github.com/JonnyWong16/plexpy/blob/master/API.md#notify @@ -59,11 +58,12 @@ def get_get_activity(): sys.stderr.write("PlexPy API 'get_activity' request failed: {0}.".format(e)) pass -def send_notification(SUBJECT_TEXT, BODY_TEXT): + +def send_notification(subject_text, body_text): # Format notification text try: - subject = SUBJECT_TEXT.format(p=p, total=cc_total) - body = BODY_TEXT.format(p=p, total=cc_total, time=TIMEOUT/60) + subject = subject_text.format(p=p, total=cc_total) + body = body_text.format(p=p, total=cc_total, time=TIMEOUT / 60) except LookupError as e: sys.stderr.write("Unable to substitute '{0}' in the notification subject or body".format(e)) @@ -71,7 +71,7 @@ def send_notification(SUBJECT_TEXT, BODY_TEXT): # Send the notification through PlexPy payload = {'apikey': PLEXPY_APIKEY, 'cmd': 'notify', - 'agent_id': AGENT_ID, + 'notifier_id': NOTIFIER_ID, 'subject': subject, 'body': body} @@ -87,6 +87,7 @@ def send_notification(SUBJECT_TEXT, BODY_TEXT): sys.stderr.write("PlexPy API 'notify' request failed: {0}.".format(e)) return None + if __name__ == '__main__': parser = argparse.ArgumentParser() diff --git a/notify/notify_newip.py b/notify/notify_newip.py index d3f624d..8307ade 100644 --- a/notify/notify_newip.py +++ b/notify/notify_newip.py @@ -1,4 +1,3 @@ - """ Pulling together User IP information and Email. @@ -9,7 +8,9 @@ PlexPy > Settings > Notification Agents > Scripts > Gear icon: Playback Start: notify_newip.py Arguments passed from PlexPy --sn {show_name} -ena {episode_name} -ssn {season_num00} -enu {episode_num00} -srv {server_name} -med {media_type} -pos {poster_url} -tt {title} -sum {summary} -lbn {library_name} -ip {ip_address} -us {user} -uid {user_id} -pf {platform} -pl {player} -da {datestamp} -ti {timestamp} +-sn {show_name} -ena {episode_name} -ssn {season_num00} -enu {episode_num00} -srv {server_name} -med {media_type} +-pos {poster_url} -tt {title} -sum {summary} -lbn {library_name} -ip {ip_address} -us {user} -uid {user_id} +-pf {platform} -pl {player} -da {datestamp} -ti {timestamp} """ @@ -17,11 +18,10 @@ import argparse import requests import sys - ## EDIT THESE SETTINGS ## -PLEXPY_APIKEY = 'XXXX' # Your PlexPy API key +PLEXPY_APIKEY = '' # Your PlexPy API key PLEXPY_URL = 'http://localhost:8181/' # Your PlexPy URL -NOTIFICATION_ID = 10 # The notification agent ID for PlexPy 10 = Email +NOTIFIER_ID = 12 # The notification notifier ID # Replace LAN IP addresses that start with the LAN_SUBNET with a WAN IP address # to retrieve geolocation data. Leave REPLACEMENT_WAN_IP blank for no replacement. @@ -38,16 +38,19 @@ BODY_TEXT = """\
Hi!
- {p.user} has watched {p.media_type}:{p.title} from a new IP address: {p.ip_address}
-
On {p.platform}[{p.player}] in {g.city}, {g.country} {g.postal_code} at {p.timestamp} on {p.datestamp}
+
+ {p.user} has watched {p.media_type}:{p.title} from a new IP address: {p.ip_address}
+
On {p.platform}[{p.player}] in
+ {g.city}, {g.country} {g.postal_code}
+ at {p.timestamp} on {p.datestamp}
User email is: {u.email}