Skip to content

Commit 6e2d03b

Browse files
committed
Merge pull request #11 from jakewaldron/dev
Dev
2 parents d889c14 + ded9238 commit 6e2d03b

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ The config file is in the scripts folder. Before first run of the script, pleas
9090

9191
#####Web
9292
* web_enabled - Enable the creation of the web page
93+
* web_only_save_images - Will not create the index.html, but will still save images to the image folder.
9394
* web_domain - Domain name of the web page
9495
* web_path - Path on the domain to the web page
9596
* web_delete_previous_images - True to delete all .jpg images in the web image folder prior to copying over current images
@@ -109,6 +110,7 @@ The config file is in the scripts folder. Before first run of the script, pleas
109110
* email_use_bcc - True to send emails on using bcc instead of to (email_to settings will send to them using bcc)
110111
* email_to - Array of email addresses to send the email
111112
* email_to_send_to_shared_users - True to get list of shared user emails (plex_username and plex_password must be valid for this to be used)
113+
* email_unsubscribe - List of emails to exclude (emails in email_to will override emails in this)
112114
* email_from - Email address to send the email from
113115
* email_from_name - Friendly name of sender
114116
* email_smtp_address - SMTP address of the email service
@@ -220,4 +222,4 @@ TV Seasons:
220222
![alt tag](http://i.imgur.com/fF7HNL4.jpg)
221223

222224
TV Episodes:
223-
![alt tag](http://i.imgur.com/xiwUNPT.jpg)
225+
![alt tag](http://i.imgur.com/xiwUNPT.jpg)

scripts/config.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ email_use_bcc = False
4242
email_to = ['']
4343
#This requires plex_username and plex_password to be filled to get emails of shared users.
4444
email_to_send_to_shared_users = False
45+
email_unsubscribe = ['']
4546
email_from = ''
4647
email_from_name = 'Plex Server'
4748
email_smtp_address = 'smtp.gmail.com'

scripts/plexEmail.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424

2525
def replaceConfigTokens():
2626
## The below code is for backwards compatibility
27+
if ('email_unsubscribe' not in config):
28+
config['email_unsubscribe'] = []
29+
2730
if ('email_use_bcc' not in config):
2831
config['email_use_bcc'] = False
2932

@@ -319,6 +322,10 @@ def addheader(message, headername, headervalue):
319322
return message
320323

321324
def sendMail(email):
325+
#First check if email is in the unsubscribe list
326+
if email != '' and email[0].upper() in (name.upper() for name in config['email_unsubscribe']):
327+
print email[0] + ' is in the unsubscribe list. Do not send an email.'
328+
return 0;
322329
gmail_user = config['email_username']
323330
gmail_pwd = config['email_password']
324331
smtp_address = config['email_smtp_address']
@@ -375,6 +382,8 @@ def sendMail(email):
375382
server.login(gmail_user, gmail_pwd)
376383
server.sendmail(FROM, TO, msg.as_string())
377384
server.close()
385+
386+
return 1;
378387

379388
def createEmailHTML():
380389
emailText = """<!DOCTYPE html>
@@ -1044,16 +1053,16 @@ def createWebHTML():
10441053

10451054
emailCount = 0
10461055
if (testMode):
1047-
sendMail([config['email_from']])
1048-
emailCount += 1
1056+
success = sendMail([config['email_from']])
1057+
emailCount += success
10491058
elif (config['email_individually']):
10501059
for emailAdd in config['email_to']:
10511060
email = [emailAdd]
1052-
sendMail(email)
1053-
emailCount += 1
1061+
success = sendMail(email)
1062+
emailCount += success
10541063
else:
1055-
sendMail('')
1056-
emailCount += 1
1064+
success = sendMail('')
1065+
emailCount += success
10571066
print 'Successfully sent %s email(s)' % emailCount
10581067
# except:
10591068
# print "Failed to send email(s)"

0 commit comments

Comments
 (0)