Last active
October 2, 2017 09:52
-
-
Save JonnyWong16/2fbd4aeff11bc2452db3 to your computer and use it in GitHub Desktop.
Send an Email notification when a specific show is added to Plex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = '[email protected]' # From email address | |
to = '[email protected]' # 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 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
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.