From 3c6ee9966d7c8cb80b0927d6418172604b137fbe Mon Sep 17 00:00:00 2001 From: blacktwin Date: Fri, 30 Sep 2016 10:20:05 -0400 Subject: [PATCH] Kill script early if show is not in lists The script will stop if the show is not found in lists. Before, non listed shows were trying to be sent without emails addresses, causing errors. --- notify_on_added.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/notify_on_added.py b/notify_on_added.py index c1c7d67..120adae 100644 --- a/notify_on_added.py +++ b/notify_on_added.py @@ -42,6 +42,12 @@ users = [{'email': 'user1@gmail.com', 'shows': ('show1', 'show2', 'show3', 'show4') }] +# Kill script now if show_name is not in lists +to = list('Match' for u in users if p.show_name in u['shows']) +if not to: + exit + +# Join email addresses to = ','.join([u['email'] for u in users if p.show_name in u['shows']]) # Email settings