From be8f838fc7014815cf1f76d930f4cf825bf29722 Mon Sep 17 00:00:00 2001 From: blacktwin Date: Wed, 28 Sep 2016 14:47:36 -0400 Subject: [PATCH] Simplified loop Changed to dictionary from list. --- notify_on_added.py | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/notify_on_added.py b/notify_on_added.py index 064a8f1..99ccfd4 100644 --- a/notify_on_added.py +++ b/notify_on_added.py @@ -17,34 +17,18 @@ title = sys.argv[8] summary = sys.argv[9] library_name = sys.argv[10] -show_notify = '' -to = [] - -# User list -# setting user's shows they want notifications for -user1_list = ["show1", "show2"] -user2_list = ["show1", "show3"] -user3_list = ["show1", "show4"] -user4_list = ["show1", "show2", "show3", "show4"] - -# Email list -user_1 = ["user1@gmail.com", user1_list] -user_2 = ["user2@gmail.com", user2_list] -user_3 = ["user3@gmail.com", user3_list] -user_4 = ["user4@gmail.com", user4_list] -user_all = [user_1, user_2, user_3, user_4] - -# If show matches user's list then the user's email is added -for n in user_all[0:len(user_all)]: - user_list = n[1] - master_list = user_list[0:len(user_list)] - for x in master_list: - check_0 = x, n[0] - if show_name == check_0[0]: - to.append( check_0[1] ) - -# 'to' needs to be converted to a str -to = ', '.join(map(str, to)) +# Edit user@email.com and shows +users = [{'email': 'user1@gmail.com', + 'shows': ('show1', 'show2') + }, + {'email': 'user2@gmail.com', + 'shows': ('show1', 'show2', 'show3') + }, + {'email': 'user3@gmail.com', + 'shows': ('show1', 'show2', 'show3', 'show4') + }] + +to = ','.join([u['email'] for u in users if show_name in u['shows']]) # Email settings name = 'PlexPy' # Your name