PlexEmail - Email Recently Added Media

I have tried single "\" and double "\\" to no avail.  Here is a copy of my config file.  I only uploaded the parts that I have touched.  Everything below the Filtering has been untouched.

# This Python file uses the following encoding: utf-8
##Folder Paths
# Windows Example:   'C:\\Users\\{User Name}\\AppData\\Local\\'
# Linux Example: '/var/lib/plexmediaserver/Library/Application Support/'
# Mac Example: '/Users/{User Name}/Library/Application Support/'
plex_data_folder = 'C:\\Users\\Luke\\AppData\\Local\\'
# Windows Example:   'C:\\wamp\\www\\'
# Linux/Mac Example: '/var/www/'
web_folder = 'C:\\xampp\\htdocs\\PlexEmail'
 
##General
date_format = '%m/%d/%y'
date_days_back_to_search = 1
date_hours_back_to_search = 0
date_minutes_back_to_search = 0
 
##Image Upload - If this option is enabled, image hosting will be used for web and email
#Cloudinary - Sign up for a free account at: http://cloudinary.com/
upload_use_cloudinary = True
upload_cloudinary_cloud_name = '*****'
upload_cloudinary_api_key = '*****'
upload_cloudinary_api_secret = '*****'
 
##Web
web_enabled = True
#This will not create the index.html file, but will still save the images to the images folder.  (Useful for when you only want to send an email)
web_only_save_images = False
web_path = 'plexemail'
web_delete_previous_images = True
web_skip_if_no_additions = True
 
##Email
email_enabled = True
email_individually = False
# ['email1@gmail.com', 'email2@hotmail.com']
email_to = ['*****@gmail.com']
email_from = '*****@gmail.com'
email_from_name = 'Plex Server'
email_smtp_address = 'smtp.gmail.com'
email_smtp_port = 587
email_use_ssl = False #Port must be an SSL port i.e. 465
email_username = '*****@gmail.com'
email_password = '*****'
# Only valid if web_enabled = True and upload_use_cloudinary = True
email_use_web_images = True
email_skip_if_no_additions = True
 
##Filtering
filter_include_plex_web_link = True
filter_show_movies = True
filter_show_shows = True
filter_show_seasons = True
filter_show_episodes = True
#Name of libraries to filter out - ['Home Videos', 'Private']
filter_libraries = []
#The sections to include and ordering - tagline, summary, content_rating, duration, year, rating, studio, tags_genre, tags_director, tags_star

I have tried single "\" and double "\\" to no avail.  Here is a copy of my config file.  I only uploaded the parts that I have touched.  Everything below the Filtering has been untouched.

# This Python file uses the following encoding: utf-8
##Folder Paths
# Windows Example:   'C:\\Users\\{User Name}\\AppData\\Local\\'
# Linux Example: '/var/lib/plexmediaserver/Library/Application Support/'
# Mac Example: '/Users/{User Name}/Library/Application Support/'
plex_data_folder = 'C:\\Users\\Luke\\AppData\\Local\\'
# Windows Example:   'C:\\wamp\\www\\'
# Linux/Mac Example: '/var/www/'
web_folder = 'C:\\xampp\\htdocs\\PlexEmail'
 
##General
date_format = '%m/%d/%y'
date_days_back_to_search = 1
date_hours_back_to_search = 0
date_minutes_back_to_search = 0
 
##Image Upload - If this option is enabled, image hosting will be used for web and email
#Cloudinary - Sign up for a free account at: http://cloudinary.com/
upload_use_cloudinary = True
upload_cloudinary_cloud_name = '*****'
upload_cloudinary_api_key = '*****'
upload_cloudinary_api_secret = '*****'
 
##Web
web_enabled = True
#This will not create the index.html file, but will still save the images to the images folder.  (Useful for when you only want to send an email)
web_only_save_images = False
web_path = 'plexemail'
web_delete_previous_images = True
web_skip_if_no_additions = True
 
##Email
email_enabled = True
email_individually = False
# ['email1@gmail.com', 'email2@hotmail.com']
email_to = ['*****@gmail.com']
email_from = '*****@gmail.com'
email_from_name = 'Plex Server'
email_smtp_address = 'smtp.gmail.com'
email_smtp_port = 587
email_use_ssl = False #Port must be an SSL port i.e. 465
email_username = '*****@gmail.com'
email_password = '*****'
# Only valid if web_enabled = True and upload_use_cloudinary = True
email_use_web_images = True
email_skip_if_no_additions = True
 
##Filtering
filter_include_plex_web_link = True
filter_show_movies = True
filter_show_shows = True
filter_show_seasons = True
filter_show_episodes = True
#Name of libraries to filter out - ['Home Videos', 'Private']
filter_libraries = []
#The sections to include and ordering - tagline, summary, content_rating, duration, year, rating, studio, tags_genre, tags_director, tags_star

Hmm that looks good to me.  Of the fields you masked (cloudinary fields and email info) do any of the values include a \

If so, could you add one more \ to it?  If you don't, I can upload a new file with your info minus the filtered out stuff.

No "\"'s at all.  The Cloudinary secret has 2 underscores(_) in it, but no slashes.  I would be happy to send you my full config file if you could take a look at it?  If you want send an email to plexwebserver@gmail.com and I will reply with the full file.

Thanks!

I think I found one that was missing.  I now get the following error:

C:\xampp\htdocs\PlexEmail\scripts>plexEmail.py
Traceback (most recent call last):
  File "C:\xampp\htdocs\PlexEmail\scripts\plexEmail.py", line 689, in
    deleteImages()
  File "C:\xampp\htdocs\PlexEmail\scripts\plexEmail.py", line 159, in deleteImag
es
    for file in os.listdir(folder):
WindowsError: [Error 3] The system cannot find the path specified: 'C:\\xampp\\h
tdocs\\PlexEmail\\plexemail\\images\\*.*'

I think I found one that was missing.  I now get the following error:

C:\xampp\htdocs\PlexEmail\scripts>plexEmail.py
Traceback (most recent call last):
  File "C:\xampp\htdocs\PlexEmail\scripts\plexEmail.py", line 689, in
    deleteImages()
  File "C:\xampp\htdocs\PlexEmail\scripts\plexEmail.py", line 159, in deleteImag
es
    for file in os.listdir(folder):
WindowsError: [Error 3] The system cannot find the path specified: 'C:\\xampp\\h
tdocs\\PlexEmail\\plexemail\\images\\*.*'

Ok, that's good news!

The web_folder should be the path to the web directory, so in your case it should be 'C:\\xampp\\htcdocs\\

web_path under the Web section will automatically add it to the path (although if you want it in PlexEmail instead of plexemail, you will want to set web_path to PlexEmail).

I removed the PlexEmail from the web_folder and still had the same results.  I then changed the web_path to PlexEmail and still no go.  Same error:

C:\xampp\htdocs\PlexEmail\scripts>plexEmail.py
Traceback (most recent call last):
  File "C:\xampp\htdocs\PlexEmail\scripts\plexEmail.py", line 689, in
    deleteImages()
  File "C:\xampp\htdocs\PlexEmail\scripts\plexEmail.py", line 159, in deleteImag
es
    for file in os.listdir(folder):
WindowsError: [Error 3] The system cannot find the path specified: 'C:\\xampp\\h
tdocs\\PlexEmail\\plexemail\\images\\*.*'

I removed the PlexEmail from the web_folder and still had the same results.  I then changed the web_path to PlexEmail and still no go.  Same error:

C:\xampp\htdocs\PlexEmail\scripts>plexEmail.py
Traceback (most recent call last):
  File "C:\xampp\htdocs\PlexEmail\scripts\plexEmail.py", line 689, in
    deleteImages()
  File "C:\xampp\htdocs\PlexEmail\scripts\plexEmail.py", line 159, in deleteImag
es
    for file in os.listdir(folder):
WindowsError: [Error 3] The system cannot find the path specified: 'C:\\xampp\\h
tdocs\\PlexEmail\\plexemail\\images\\*.*'

Hmm, the error still indicates that plexemail is in both the web_folder and the web_path.

Set web_folder to: 'C:\\xampp\\htdocs\\'

and web_path to: 'PlexEmail'

Also, did you extract the web folder to C:\xampp\htcdocs\PlexEmail\?

I deleted everything and I am starting from scratch again because I believe there was something just out whack with my install.  Question though.  Do I need to put the contents of the web folder in the PlexEmail folder?  Or just leave everything in the web folder nested under the PlexEmail folder?

After deleting everything and running the script again, I get the following:

C:\xampp\htdocs\plexemail\scripts>plexEmail.py
Traceback (most recent call last):
  File "C:\xampp\htdocs\plexemail\scripts\plexEmail.py", line 926, in
    imageInfo = processImage(hash, imageInfo['thumb'], 'episode', tvEpisodes[epi
sode]['season_index'], tvEpisodes[episode]['index'])
  File "C:\xampp\htdocs\plexemail\scripts\plexEmail.py", line 224, in processIma
ge
    shutil.copy(imgLocation, img)
  File "C:\Python27\lib\shutil.py", line 119, in copy
    copyfile(src, dst)
  File "C:\Python27\lib\shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 2] No such file or directory: 'C:\\xampp\\htdocs\\plexemail\\ple
xemail\\images\\7b2ef48214a0438718e3cb91d808fe8684b41211_1724546b10dcfe956b5ae1c
04d7d05002b560e7b.jpg'

I deleted everything and I am starting from scratch again because I believe there was something just out whack with my install.  Question though.  Do I need to put the contents of the web folder in the PlexEmail folder?  Or just leave everything in the web folder nested under the PlexEmail folder?

Put the contents of the web folder into the PlexEmail folder.  So for example the images folder will go here: C:\xampp\htdocs\PlexEmail\images\

Also for your web_domain could you end it with /.  i.e. 'http://www.somedomain.com/'(I'll update the code for the next version to handle it both ways, but it needs it now)

After deleting everything and running the script again, I get the following:

C:\xampp\htdocs\plexemail\scripts>plexEmail.py
Traceback (most recent call last):
  File "C:\xampp\htdocs\plexemail\scripts\plexEmail.py", line 926, in
    imageInfo = processImage(hash, imageInfo['thumb'], 'episode', tvEpisodes[epi
sode]['season_index'], tvEpisodes[episode]['index'])
  File "C:\xampp\htdocs\plexemail\scripts\plexEmail.py", line 224, in processIma
ge
    shutil.copy(imgLocation, img)
  File "C:\Python27\lib\shutil.py", line 119, in copy
    copyfile(src, dst)
  File "C:\Python27\lib\shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 2] No such file or directory: 'C:\\xampp\\htdocs\\plexemail\\ple
xemail\\images\\7b2ef48214a0438718e3cb91d808fe8684b41211_1724546b10dcfe956b5ae1c
04d7d05002b560e7b.jpg'

It still looks like there is a plexemail in the web_folder and a plexemail in the web_path.  Could you send me another email with the config file.  I'll make sure it looks good and update it if it needs updating.

Sent via email.

Your changes you proposed earlier did the trick!  Thanks for all of the help!  I am super pumped about this program.

 

Put the contents of the web folder into the PlexEmail folder.  So for example the images folder will go here: C:\xampp\htdocs\PlexEmail\images\

Also for your web_domain could you end it with /.  i.e. 'http://www.somedomain.com/'(I'll update the code for the next version to handle it both ways, but it needs it now)

Hey,

Just wondering if I could make a request? Or if it is already implemented maybe someone can point me in the right direction.

Here is my idea, when I download a new Series, I might get 60-80 shows in one day (depending how long the show has been around of course). As it is now, the email that is sent out will have data for each and everyone of those shows making for a really, really long email. Is there anyway to group these episodes of the same show into one listing?

Hey,

Just wondering if I could make a request? Or if it is already implemented maybe someone can point me in the right direction.

Here is my idea, when I download a new Series, I might get 60-80 shows in one day (depending how long the show has been around of course). As it is now, the email that is sent out will have data for each and everyone of those shows making for a really, really long email. Is there anyway to group these episodes of the same show into one listing?

The script already handles that in a way,  When it is creating the item for each episode it will check if the season it is a part of is also new.  If the season is also new it will not add each individual episode to the list.  Depending on the frequency that the script is running, some of the episodes might be added the first run of the script and won't be shown, but all other episodes added on the next run will be shown (since the season is not new anymore).

The script already handles that in a way,  When it is creating the item for each episode it will check if the season it is a part of is also new.  If the season is also new it will not add each individual episode to the list.  Depending on the frequency that the script is running, some of the episodes might be added the first run of the script and won't be shown, but all other episodes added on the next run will be shown (since the season is not new anymore).

OK, that makes sense. What brought this up was there was some missing shows in a existing S02 and S04 and Sonarr was able to find and download them this week. So all of them were listed.

Hey, eadwyn. So the script has been running fine for me for weeks now, but I recently reazlied it had stopped. When I ran the script manually from the command line, this was my result:

C:\Python27\Scripts>python plexemail.py
Traceback (most recent call last):
  File "plexemail.py", line 794, in 
    imageInfo = processImage(hash, imageInfo['thumb'], 'season', tvSeasons[seaso
n]['index'], 0)
  File "plexemail.py", line 204, in processImage
    cloudinaryURL = uploadToCloudinary(imgLocation)
  File "plexemail.py", line 248, in uploadToCloudinary
    response = cloudinary.uploader.upload(imgToUpload)
  File "C:\Python27\Scripts\cloudinary\uploader.py", line 16, in upload
    return call_api("upload", params, file = file, **options)
  File "C:\Python27\Scripts\cloudinary\uploader.py", line 223, in call_api
    raise Error(result["error"]["message"])
cloudinary.api.Error: Invalid image file

Any notions on what's happening here?

Hey, eadwyn. So the script has been running fine for me for weeks now, but I recently reazlied it had stopped. When I ran the script manually from the command line, this was my result:

C:\Python27\Scripts>python plexemail.py
Traceback (most recent call last):
  File "plexemail.py", line 794, in 
    imageInfo = processImage(hash, imageInfo['thumb'], 'season', tvSeasons[seaso
n]['index'], 0)
  File "plexemail.py", line 204, in processImage
    cloudinaryURL = uploadToCloudinary(imgLocation)
  File "plexemail.py", line 248, in uploadToCloudinary
    response = cloudinary.uploader.upload(imgToUpload)
  File "C:\Python27\Scripts\cloudinary\uploader.py", line 16, in upload
    return call_api("upload", params, file = file, **options)
  File "C:\Python27\Scripts\cloudinary\uploader.py", line 223, in call_api
    raise Error(result["error"]["message"])
cloudinary.api.Error: Invalid image file

Any notions on what's happening here?

Looks like and error with the API call to cloudinary. I start by checking your creds and make sure that part is still working.

Looks like and error with the API call to cloudinary. I start by checking your creds and make sure that part is still working.

Just checked my credentials, and everything appears to be working fine. Cloud name, API key and API secret are correct, and I can even see the thumbnails for the recently added content in my Cloudinary account. I have no idea why this is all of a sudden not working...

Just checked my credentials, and everything appears to be working fine. Cloud name, API key and API secret are correct, and I can even see the thumbnails for the recently added content in my Cloudinary account. I have no idea why this is all of a sudden not working...

Do you have any firewalls (peerblock?) that might block a connection?

Just checked my credentials, and everything appears to be working fine. Cloud name, API key and API secret are correct, and I can even see the thumbnails for the recently added content in my Cloudinary account. I have no idea why this is all of a sudden not working...

Please try this modified script that will output some info regarding the files being uploaded.  From the error it looks like the file might not be an actual image.  Please give me the output after running the script.

plexEmail.zip (9.9 KB)