PlexEmail - Email Recently Added Media

Think you need to remove the one of the \ in this line.
2016-08-13 13:26:08,036 - INFO:processImage: img = C:\www\html\updates\images\5448663fe3aaec5cbe353906f82a65ff

@MikeFalcor said:
I’ve just recently started seeing the following error when trying to run the script:

Traceback (most recent call last): File "plexEmail.py", line 1037, in <module> imageInfo = processImage(hash, imageInfo['thumb'], 'show', 0, 0) File "plexEmail.py", line 343, in processImage imgName = thumb[thumb.index('_') + 1:len(thumb)] ValueError: substring not found
Any help would be appreciated. Keep up the good work!

Same here, the script worked fine last week. Not sure what (if anything) has changed though…

@Kenneth Spronk said:

@MikeFalcor said:
I’ve just recently started seeing the following error when trying to run the script:

Traceback (most recent call last): File "plexEmail.py", line 1037, in <module> imageInfo = processImage(hash, imageInfo['thumb'], 'show', 0, 0) File "plexEmail.py", line 343, in processImage imgName = thumb[thumb.index('_') + 1:len(thumb)] ValueError: substring not found
Any help would be appreciated. Keep up the good work!

Same here, the script worked fine last week. Not sure what (if anything) has changed though…

I also got this error tonight :frowning:

Hmm try this fix, found it at git.

@jaycedk said:
Hmm try this fix, found it at git.
ValueError: substring not found Ā· Issue #42 Ā· jakewaldron/PlexEmail Ā· GitHub

Found that last night and it worked. Thanks.

@Peanutman said:

@jaycedk said:
Hmm try this fix, found it at git.
ValueError: substring not found Ā· Issue #42 Ā· jakewaldron/PlexEmail Ā· GitHub

Found that last night and it worked. Thanks.

@jaycedk said:
Hmm try this fix, found it at git.
ValueError: substring not found Ā· Issue #42 Ā· jakewaldron/PlexEmail Ā· GitHub

Worked for me as well, thanks!

@jaycedk said:
Hmm try this fix, found it at git.
ValueError: substring not found Ā· Issue #42 Ā· jakewaldron/PlexEmail Ā· GitHub

Many thanks for this. My own script stopped working this week, and this fixed the issue immediately.

Added the fix for the substring error and pushed the dev branch to master.

v0.8.7 Released

Bug Fixes

  • Remove duplicate emails - only email each unique address once per script run.
  • Handle cases where duration is not an int
  • Fixes an issue where the parent_id of an episode was None.
  • Check if an image is externally hosted by checking for http:// and https://
  • If date_days_back_to_search = 31, treat that as a month instead of days
  • Check if imageInfo is empty

New Features

  • Added partial logging support to help troubleshoot issues
  • Can now set Cloudinary to upload using http or https

Download here: https://github.com/jakewaldron/PlexEmail/releases/latest

I installed all the files needed to support.

I am getting this after running the script.
Any input?

C:\PlexEmail\scripts>python PlexEmail.py Traceback (most recent call last): File "PlexEmail.py", line 9, in import requests ImportError: No module named requests

Thanks in advance!

@aKwan said:
I installed all the files needed to support.

I am getting this after running the script.
Any input?

C:\PlexEmail\scripts>python PlexEmail.py Traceback (most recent call last): File "PlexEmail.py", line 9, in import requests ImportError: No module named requests

Thanks in advance!

Make sure to follow step 3 of the prerequisites. You are missing the requests library.

@eadwyn said:

@aKwan said:
I installed all the files needed to support.

I am getting this after running the script.
Any input?

C:\PlexEmail\scripts>python PlexEmail.py Traceback (most recent call last): File "PlexEmail.py", line 9, in import requests ImportError: No module named requests

Thanks in advance!

Make sure to follow step 3 of the prerequisites. You are missing the requests library.

Thank you sir… I moved the ā€œrequests-2.5.3ā€ folder into the Lib folder. :slight_smile:
Thanks for the prompt response!

Hey guys, I recently tried this over at FreeNAS of the guy who wrote the guide and ive gotten these kinds of output in the errorlog.

To me it sounds like somekind of permissions issue but id wanna ask here before doing anything to drastic.
here is a pastebin of the output:
http://pastebin.com/EXie6gBn

and yes i run the plexemail in a separate jail.

Is line 45 in the config file (email_unsubscribe = [’ ']) for unsubscribing users who wish to not receive the email or for something else?

Reason I ask is because it isn’t working as I thought it did. If this isn’t the way to unsub specific users, can it be added?

Firstly, thanks for the continued development and support on this. I’ve been using since 0.7.1 without any problems, and my Plex friends have comments how nice it is to know what I’ve added during the week (to be fair, I already know!)

Hadn’t felt the need to update as nothing was broken, but thought it was about time and I had a little spare time.

I updated by moving the existing PlexEmail folder to PlexEmail-071 and the doing a git clone to pull down the latest version, which created a new PlexEmail folder. I was going to copy across my old config.conf, but then thought there might have been some changes so decided to update this manually referencing a copy of the old file. I copied the contents of the new web folder to /usr/local/www/apache24/data/plexemail and ran the script, which worked without any issues.

The webpage was update and e-mail sent, but I’m missing some (not all) of the images. When I checked the plexEmail.log file it appears they are not uploading to cloudinary, although I’m not 100% sure. Here’s a few lines:

2016-08-19 19:45:44,388 - INFO:processImage: begin
2016-08-19 19:45:44,389 - INFO:processImage: imageHash = 046d90608e359c6eaf4c4263c86f9a6f721468fb - thumb = metadata://posters/com.$
2016-08-19 19:45:44,389 - INFO:processImage: imgLocation = /plexms/Plex Media Server/Metadata/TV Shows/0/46d90608e359c6eaf4c4263c86$
2016-08-19 19:45:44,389 - INFO:processImage: webImgFullPath = plexemail/images/d25533f8c907191086dd847e086b581a1c111a95_046d90608e3$
2016-08-19 19:45:44,389 - INFO:processImage: img = /usr/local/www/apache24/data/plexemail/images/d25533f8c907191086dd847e086b581a1c$
2016-08-19 19:45:44,389 - INFO:processImage: Uploading to cloudinary
2016-08-19 19:45:44,389 - INFO:uploadToCloudinary: begin
2016-08-19 19:45:44,389 - INFO:uploadToCloudinary: file not located
2016-08-19 19:45:44,390 - INFO:processImage: begin
2016-08-19 19:45:44,390 - INFO:processImage: imageHash = 046d90608e359c6eaf4c4263c86f9a6f721468fb - thumb = metadata://posters/com.$
2016-08-19 19:45:44,390 - INFO:processImage: imgLocation = /plexms/Plex Media Server/Metadata/TV Shows/0/46d90608e359c6eaf4c4263c86$
2016-08-19 19:45:44,391 - INFO:processImage: webImgFullPath = plexemail/images/d25533f8c907191086dd847e086b581a1c111a95_046d90608e3$
2016-08-19 19:45:44,391 - INFO:processImage: img = /usr/local/www/apache24/data/plexemail/images/d25533f8c907191086dd847e086b581a1c$
2016-08-19 19:45:44,391 - INFO:processImage: Uploading to cloudinary
2016-08-19 19:45:44,391 - INFO:uploadToCloudinary: begin
2016-08-19 19:45:44,391 - INFO:uploadToCloudinary: file not located
2016-08-19 19:45:44,391 - INFO:processImage: begin
2016-08-19 19:45:44,391 - INFO:processImage: imageHash = b2c2a64800ec267f03bed25dc7d72fed2870107d - thumb = metadata://posters/com.$
2016-08-19 19:45:44,391 - INFO:processImage: imgLocation = /plexms/Plex Media Server/Metadata/TV Shows/b/2c2a64800ec267f03bed25dc7d$
2016-08-19 19:45:44,391 - INFO:processImage: webImgFullPath = plexemail/images/329d7a6533b112bdcbc1a5b58bfea273e2d38129_b2c2a64800e$
2016-08-19 19:45:44,391 - INFO:processImage: img = /usr/local/www/apache24/data/plexemail/images/329d7a6533b112bdcbc1a5b58bfea273e2$
2016-08-19 19:45:44,391 - INFO:processImage: Uploading to cloudinary
2016-08-19 19:45:44,391 - INFO:uploadToCloudinary: begin
2016-08-19 19:45:44,391 - INFO:uploadToCloudinary: start upload to cloudinary
2016-08-19 19:45:44,926 - INFO:uploadToCloudinary: response = {u’secure_url’: u’https://res.cloudinary.com/adrianwiuk/image/upload/$
2016-08-19 19:45:44,926 - INFO:uploadToCloudinary: url = http://res.cloudinary.com/adrianwiuk/image/upload/v1471632344/gm1qs3bokhbf$
2016-08-19 19:45:44,926 - INFO:processImage: Setting image paths to cloudinary
2016-08-19 19:45:44,927 - INFO:processImage: begin
2016-08-19 19:45:44,927 - INFO:processImage: imageHash = 1a2fb225feddcafac90078975ff93d2d56645dca - thumb = metadata://posters/com.$
2016-08-19 19:45:44,927 - INFO:processImage: imgLocation = /plexms/Plex Media Server/Metadata/TV Shows/1/a2fb225feddcafac90078975ff$
2016-08-19 19:45:44,927 - INFO:processImage: webImgFullPath = plexemail/images/076b98166455cf29d721b567363161d791ce5bfc_1a2fb225fed$
2016-08-19 19:45:44,927 - INFO:processImage: img = /usr/local/www/apache24/data/plexemail/images/076b98166455cf29d721b567363161d791$
2016-08-19 19:45:44,927 - INFO:processImage: Uploading to cloudinary

When I look at the link for the image in the e-mail, it directs me to plex.tv, where I thought this would be hitting cloudinary?

I’ve looked a little more and it appears to be just the episode images that haven’t uploaded to cloudinary (the movie posters and season posters have)

Any ideas?

UPDATE

I might have figured this out! Scanning through the config.conf file I noticed the option for filter_episode_thumbnail_type so changed this to ā€˜episode’ which now shows the images. I’m still missing one image for The Walking Dead Season 7 (downloaded the preview episode as S07E00) but that might be down to the lack of a poster in Plex. It picked up Mr Robot Season 2 which I’ve recently added, so I suspect just a minor glitch.

@lazybones02 said:
Hey guys, I recently tried this over at FreeNAS of the guy who wrote the guide and ive gotten these kinds of output in the errorlog.

To me it sounds like somekind of permissions issue but id wanna ask here before doing anything to drastic.
here is a pastebin of the output:
http://pastebin.com/EXie6gBn

and yes i run the plexemail in a separate jail.

Yeah, this sounds like a permissions issue. Make sure that the user running the script has read/write access to the plex installation.

@Semperfratres said:
Is line 45 in the config file (email_unsubscribe = [’ ']) for unsubscribing users who wish to not receive the email or for something else?

Reason I ask is because it isn’t working as I thought it did. If this isn’t the way to unsub specific users, can it be added?

Are you sending one email to everyone or individually sending emails? Looking though the code it looks like the unsubscribe only works for individual emails (I will fix it in the next release to work for both).

@adrianwi said:
Firstly, thanks for the continued development and support on this. I’ve been using since 0.7.1 without any problems, and my Plex friends have comments how nice it is to know what I’ve added during the week (to be fair, I already know!)

Hadn’t felt the need to update as nothing was broken, but thought it was about time and I had a little spare time.

I updated by moving the existing PlexEmail folder to PlexEmail-071 and the doing a git clone to pull down the latest version, which created a new PlexEmail folder. I was going to copy across my old config.conf, but then thought there might have been some changes so decided to update this manually referencing a copy of the old file. I copied the contents of the new web folder to /usr/local/www/apache24/data/plexemail and ran the script, which worked without any issues.

The webpage was update and e-mail sent, but I’m missing some (not all) of the images. When I checked the plexEmail.log file it appears they are not uploading to cloudinary, although I’m not 100% sure. Here’s a few lines:

When I look at the link for the image in the e-mail, it directs me to plex.tv, where I thought this would be hitting cloudinary?

I’ve looked a little more and it appears to be just the episode images that haven’t uploaded to cloudinary (the movie posters and season posters have)

Any ideas?

UPDATE

I might have figured this out! Scanning through the config.conf file I noticed the option for filter_episode_thumbnail_type so changed this to ā€˜episode’ which now shows the images. I’m still missing one image for The Walking Dead Season 7 (downloaded the preview episode as S07E00) but that might be down to the lack of a poster in Plex. It picked up Mr Robot Season 2 which I’ve recently added, so I suspect just a minor glitch.

Glad to hear you figured it out. In a future release I will look at making it more robust by trying episode/season/show for an existing image instead of just not having an image at all if the preferred is not found.

With the newest update, I’m getting the following error:

2016-08-21 12:15:01,768 - ERROR:Logging an uncaught exception
Traceback (most recent call last):
  File "/app/plexemail/scripts/plexEmail.py", line 1064, in <module>
    imageInfo = processImage(hash, imageInfo['thumb'], 'movie', 0, 0)
  File "/app/plexemail/scripts/plexEmail.py", line 420, in processImage
    cloudinaryURL = uploadToCloudinary(imgLocation)
  File "/app/plexemail/scripts/plexEmail.py", line 480, in uploadToCloudinary
    url = response['secure_url'] if (config['upload_cloudinary_use_https']) else response['url']
KeyError: 'upload_cloudinary_use_https'

Any idea what’s causing this?

@Peanutman said:
With the newest update, I’m getting the following error:

2016-08-21 12:15:01,768 - ERROR:Logging an uncaught exception
Traceback (most recent call last):
  File "/app/plexemail/scripts/plexEmail.py", line 1064, in <module>
    imageInfo = processImage(hash, imageInfo['thumb'], 'movie', 0, 0)
  File "/app/plexemail/scripts/plexEmail.py", line 420, in processImage
    cloudinaryURL = uploadToCloudinary(imgLocation)
  File "/app/plexemail/scripts/plexEmail.py", line 480, in uploadToCloudinary
    url = response['secure_url'] if (config['upload_cloudinary_use_https']) else response['url']
KeyError: 'upload_cloudinary_use_https'

Any idea what’s causing this?

A new field in the config file was added: upload_cloudinary_use_https

You can either add this:

upload_cloudinary_use_https = True

Or take the latest code push to the master branch which adds backwards compatibility for this field.

@eadwyn said:
Added the fix for the substring error and pushed the dev branch to master.

v0.8.7 Released

Bug Fixes

  • Remove duplicate emails - only email each unique address once per script run.
  • Handle cases where duration is not an int
  • Fixes an issue where the parent_id of an episode was None.
  • Check if an image is externally hosted by checking for http:// and https://
  • If date_days_back_to_search = 31, treat that as a month instead of days
  • Check if imageInfo is empty

New Features

  • Added partial logging support to help troubleshoot issues
  • Can now set Cloudinary to upload using http or https

Download here: Release Plex Email v0.9.3 Ā· jakewaldron/PlexEmail Ā· GitHub

Dear @eadwyn
I“ve created a thread in the QNAP forum as a guide to install and configure the script in the QNAP NAS.
https://forum.qnap.com/viewtopic.php?f=177&t=125414
Feel free to use it, edit or link it to the GitHub page as a specific section for the QNAP users.
Best regards

Dear @eadwyn
I“ve created a thread in the QNAP forum as a guide to install and configure the script in the QNAP NAS.
https://forum.qnap.com/viewtopic.php?f=177&t=125414
Feel free to use it, edit or link it to the GitHub page as a specific section for the QNAP users.
Best regards

Thanks for doing that! I’m sure other QNAP users will appreciate it.

Having an issue running the email script, here’s the log:

2016-08-26 16:40:22,621 - INFO:Test flag found - setting script instance to test mode. 2016-08-26 16:40:22,621 - INFO:Including Plex Web Link - Getting machine identifier from the DLNA DB 2016-08-26 16:40:22,621 - INFO:DLNA_DB_FILE = H:\Plex Media Server\Plug-in Support\Databases\com.plexapp.dlna.db 2016-08-26 16:40:22,622 - INFO:plexWebLink = http://plex.tv/web/app#!/server/75f07ba1582b05731d9c62244bba3bbe0ff6a3fd/details/%2Flibrary%2Fmetadata%2F 2016-08-26 16:40:22,622 - INFO:plexWebLink = http://plex.tv/web/app#!/server/a4812ee93bc791999ca4f9a4e7673181907b3a6b/details/%2Flibrary%2Fmetadata%2F 2016-08-26 16:40:22,624 - INFO:Executing DB query: SELECT MD.id, MD.parent_id, MD.metadata_type, MD.title, MD.title_sort, MD.original_title, MD.rating, MD.tagline, MD.summary, MD.content_rating, MD.duration, MD.user_thumb_url, MD.tags_genre, MD.tags_director, MD.tags_star, MD.year, MD.hash, MD.[index], MD.studio, ME.duration, MD.originally_available_at FROM metadata_items MD LEFT OUTER JOIN media_items ME ON MD.id = ME.metadata_item_id WHERE added_at >= datetime('now', 'localtime', '-7 days', '-0 hours', '-0 minutes') AND metadata_type >= 1 AND metadata_type <= 10 ORDER BY title_sort; 2016-08-26 16:40:22,647 - INFO:processImage: begin 2016-08-26 16:40:22,647 - INFO:processImage: imageHash = f00f8ea579f01fa910fae75e33f720e2b90abdf3 - thumb = winner-take-all battle of their lives.PG-13 €,€metadata://posters/com.plexapp.agents.them - mediaType = movie - seasonIndex = 0 - episodeIndex = 0 2016-08-26 16:40:22,647 - ERROR:Logging an uncaught exception Traceback (most recent call last): File "H:\PlexEmail\scripts\plexEmail.py", line 1067, in <module> imageInfo = processImage(hash, imageInfo['thumb'], 'movie', 0, 0) File "H:\PlexEmail\scripts\plexEmail.py", line 390, in processImage imgName = thumb[thumb.index('_') + 1:len(thumb)] ValueError: substring not found

The part that stood out was: ā€œwinner-take-all battle of their livesā€, which seems to be metadata for the movie ā€˜Warrior’. I have removed this movie from my plex collection, update library, tried the script again, same error. I tried to change the metadata, unmatch, rematch, even remove this line from the metadata and it still prevails.

Any ideas? Thanks!