-
-
Save JonnyWong16/2fbd4aeff11bc2452db3 to your computer and use it in GitHub Desktop.
| from email.mime.text import MIMEText | |
| import email.utils | |
| import smtplib | |
| import sys | |
| # Arguments passed from PlexPy | |
| # {show_name} {episode_name} {season_num} {episode_num} | |
| show_name = sys.argv[1] | |
| # You can add more arguments if you want more details in the email body | |
| # episode_name = sys.argv[2] | |
| # season_num = sys.argv[3] | |
| # episode_num = sys.argv[4] | |
| show_notify = 'Game of Thrones' # The show name you want notifications to send | |
| # Email settings | |
| name = 'Your name' # Your name | |
| from = 'from_email_address@domain.com' # From email address | |
| to = 'to_email_address@domain.com' # To email address | |
| email_server = 'smtp.gmail.com' # Email server (Gmail: smtp.gmail.com) | |
| email_port = 587 # Email port (Gmail: 587) | |
| email_username = 'username' # Your email username | |
| email_password = 'password' # Your email password | |
| email_subject = 'Recently added to Plex' # The email subject | |
| email_body = 'New episode for ' + show_name + ' is available!' # The email body | |
| # email_body = 'New episode for ' + show_name + ' (S' + season_num + 'E' + episode_num + ') is available!' # More detailed email body | |
| ### Do not edit below ### | |
| # Check if the show name is the one we want | |
| if show_name.lower() == show_notify.lower(): | |
| message = MIMEText(email_body, 'plain', "utf-8") | |
| message['Subject'] = email_subject | |
| message['From'] = email.utils.formataddr((name, from)) | |
| message['To'] = to | |
| mailserver = smtplib.SMTP(email_server, email_port) | |
| mailserver.starttls() | |
| mailserver.ehlo() | |
| mailserver.login(email_username, email_password) | |
| mailserver.sendmail(from, to, message.as_string()) | |
| mailserver.quit() | |
| else: | |
| return |
Hello @mp998,
I am trying to use this script you created but whenever a item is added and the script executed, I get the following error in the log and no email is sent:
PlexPy Notifiers :: Script returned: Traceback (most recent call last):
File "C:\Program Files (x86)\PlexPY\Scripts\PlexPy_email_notifiation.py", line 8, in
show_name = sys.argv[1]
IndexError: list index out of range
Any ideas on why I may be getting this error? I am not a python guy but some research on the error seems to suggest that a parameter needs to be passed to the script but I thought plexpy would do that. Any suggestions would be greatly appreciated. Thanks in advance.
Hi all,
Any idea why I cannot get season and episode number? Here the body of my email
Ciao!
NCIS: New Orleans S00 - E01 -- -- aggiunto a Spettacoli TV su PLEX
As you can see for every shows I got S00 and E01. Thanks for your help
I'm using PlexPy for Notifications and I had the same problem.
I resolved it by unchecking "Group notifications for recently added TV Shows or Music" under Notifications settings
Hi - How can I make this work for multiple shows - eg: My wife watches Greys Anatomy and Empire and I want her to get emails for any new episodes of those 2 shows.
Thanks
I played with the code a little and found a workaround for embedding the poster in the email. I also changed it so instead of matches it by the shows name it will send if it is the correct type (movie/episode).
Here is what it looks like:

Here is the link to the script
https://gist.github.com/mp998/1fc3a1abcdaa5ffe167986fef3dc7ff8