Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

PlexEmail - Email Recently Added Media

eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass
PayPal donate button

Plex Email


Update 2/26/2016: 
This script has been updated to now handle music along with TV and movies.

Hey everyone.  The other day I saw someone looking for an application that could send out a newsletter email with recently added TV and movies from the previous week. The only options that I could find were PlexWatch, which sends out emails for every new addition and PlexReport which does not support Windows.

 

So I decided to create my own script that can work on all OSes (that can execute a python script) which would send out an email once a week to a configured list of recipients.  While I was doing this, I decided to have it also create a web page that can be viewed outside email (this requires a web server).

 

The script has already expanded to be fairly configurable, so please look at the Readme to see all the options.

 

Github Repo: https://github.com/jakewaldron/PlexEmail

Latest Release: https://github.com/jakewaldron/PlexEmail/releases/latest

Readme: https://github.com/jakewaldron/PlexEmail/blob/master/README.md (screenshots included here)

 

Donations: I've recently been asked about donations.  If you would like to donate to this project, you can do so here: Paypal Donation

 

Introduction

 

This script aggregates all new TV and movie releases for the past x days then writes to your web directory and sends out an email.

 

Supported Environments

  • Windows - Tested
  • Linux - Tested
  • FreeBSD/FreeNAS - Tested
  • Mac - Not Tested

 

Supported Email Protocols

  • SMTP

 

Prerequisites

  1. Python 2.7 - Windows: 32 bit - https://www.python.org/ftp/python/2.7.9/python-2.7.9.msi
  2. 32 bit DLL for SQLite version 3.8.8.3
  3. Requests module for Python. pip install requests or download it here and put it in the LIb folder of your Python installation: https://pypi.python.org/packages/source/r/requests/requests-2.5.3.tar.gz#md5=23bf4fcc89ea8d353eb5353bb4a475b1
  4. If web reports are wanted, a web server (apachenginxXAMPPWampServerEasyPHPlighttpdMAMP, etc)

Installation (Windows)

  1. Clone this repo or download the zip
  2. Copy the contents of scripts to where you want the script to run from
  3. Copy the contents of web to your web folder
  4. Update the config.conf file inside the scripts folder
  5. Schedule a weekly task to execute plexEmail.vbs (on windows) or plexEmail.py (on linux/mac) from the scripts folder (make sure to set the start in folder as the folder where the vbs script resides)

Installation (Linux)

  1. Install python 2.7.9
  2. pip install requests
  3. Copy the contents of scripts to where you want the script to run from
  4. Copy the contents of web to your web folder
  5. Update the config.conf file inside the scripts folder
  6. Schedule a weekly cron job to execute the plexEmail.py script


Installation (CentOS)

https://forums.plex.tv/topic/151619-plexemail-in-development/page-7#entry879778

 

Installation (FreeNAS)

Thanks to adrianwi:

https://forums.freenas.org/index.php?threads/guide-for-installing-plexemail.40748/#post-257799

 

Installation (QNAP)

Thanks to nickiman:

https://forum.qnap.com/viewtopic.php?f=177&t=125414


Usage

 

Normal Usage

python plexEmail.py

Alternate Usage

 

Pass in an alternate config file.  For example the default config file sends out a daily email (using Cloudinary), while an alternate config file is set up for a weekly web page.

python plexEmail.py -c C:\files\plexEmailWeekly.conf

Run in test mode.  This will only send the email to the sender.

python plexEmail.py -t

Config File

 

The config file is in the scripts folder. Before first run of the script, please update this file with your information.

 

 

Field Explanations:

 

Folder Paths

  • plex_data_folder - Location where the Plex Media Server folder is located - i.e. E:\\Library\\Plex\\
  • web_folder - Location of web/www/public_html folder is located - i.e. C:\\wamp\\www\\

 

General

  • date_format - Format to use for the date
  • date_days_back_to_search - Number of days to search backwards
  • date_hours_back_to_search - Number of hours to search backwards
  • date_minutes_back_to_search - Number of minutes to search backwards

 

Image Hosting

 

Cloudinary - Sign up for a free account at: http://cloudinary.com/

  • upload_use_cloudinary - Use Cloudinary image hosting
  • upload_cloudinary_cloud_name - Cloudinary cloud name
  • upload_cloudinary_api_key - Cloudinary api key
  • upload_cloudinary_api_secret - Cloudinary api secret

 

Web

  • web_enabled - Enable the creation of the web page
  • web_domain - Domain name of the web page
  • web_path - Path on the domain to the web page
  • web_delete_previous_images - True to delete all .jpg images in the web image folder prior to copying over current images
  • web_skip_if_no_additions - True to skip creating a web page if there are no new additions

 

Email

  • email_enabled - Enable the creation and sending of an email
  • email_individually - True to send out emails individually to each address in the email_to setting
  • email_to - Array of email addresses to send the email
  • email_from - Email address to send the email from
  • email_from_name - Friendly name of sender
  • email_smtp_address - SMTP address of the email service
  • email_smtp_port - SMTP port of the email service
  • email_use_ssl - Use SSL - Note that the port must be an SSL port for this to work i.e. 465
  • email_username - SMTP authentication username
  • email_password - SMTP authentication password
  • email_use_web_images - Use images from the web server instead of attaching them directly to the email
  • email_skip_if_no_additions - True to skip sending emails if there are no new additions

 

Filtering

  • filter_show_movies - True to show recently added movies
  • filter_show_shows - True to show recently added TV shows
  • filter_show_seasons - True to show recently added TV seasons
  • filter_show_episodes - True to show recently added TV episodes
  • filter_libraries - A list of library names to filter out -
  • filter_sections_movies - Movie specific filters
  • filter_sections_TV - TV specific filters
    • Possible fields: tagline, summary, content_rating, duration, year, rating, studio, tags_genre, tags_director, tags_star
    • order - The order this field should appear for each title
    • show - Whether or not this field should be shown for each title
    • preText - The text that should be added before this field for each title
    • postText - The text that should be added after this field for each title
    • include - A list of values that are each title must match at least one to be shown
    • exclude - A list of values that if the title matches any of, will not be shown

 

Messages

  • msg_email_teaser - Teaser text on the email
  • msg_web_title - Title of the webpage
  • msg_email_subject Subject of email
  • msg_header1 - First header text
  • msg_header2 - Second header text
  • msg_header3 - Third header text. Only used in the email
  • msg_top_link - Header link text to go to top of the page
  • msg_movies_link - Header link text to go to new movies
  • msg_shows_link - Header link text to go to new shows
  • msg_seasons_link - Header link text to go to new seasons
  • msg_episodes_link - Header link text to go to new episodes
  • msg_new_movies_header - Section header text for new movies
  • msg_new_shows_header - Section header text for new shows
  • msg_new_seasons_header - Section header text for new seasons
  • msg_new_episodes_header - Section header text for new episodes
  • msg_footer - Footer text at the bottom of the page
  • msg_no_new_content - Message to be displayed if no new content has been added

Sorting

  • movie_sort_1 - Highest priority sort
  • movie_sort_1_reverse - Reverse the default sort
  • movie_sort_2 - Second priority sort
  • movie_sort_2_reverse - Reverse the default sort
  • movie_sort_3 - Third Priority sort
  • movie_sort_3_reverse - Reverse the default sort

 

  • show_sort_1 - Highest priority sort

  • show_sort_1_reverse - Reverse the default sort
  • show_sort_2 - Second priority sort
  • show_sort_2_reverse - Reverse the default sort
  • show_sort_3 - Third Priority sort
  • show_sort_3_reverse - Reverse the default sort

 

  • season_sort_1 - Highest priority sort

  • season_sort_1_reverse - Reverse the default sort
  • season_sort_2 - Second priority sort
  • season_sort_2_reverse - Reverse the default sort
  • season_sort_3 - Third Priority sort
  • season_sort_3_reverse - Reverse the default sort

 

  • episode_sort_1 - Highest priority sort

  • episode_sort_1_reverse - Reverse the default sort
  • episode_sort_2 - Second priority sort
  • episode_sort_2_reverse - Reverse the default sort
  • episode_sort_3 - Third Priority sort
  • episode_sort_3_reverse - Reverse the default sort
«13456743

Comments

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass

    eadwyn thanks !!

    i have a problem when i run the python i get this error :

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
    Traceback (most recent call last):
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 227, in <module>
        indexer = thumb[thumb.index('/') + 1:thumb.index('_')]
    ValueError: substring not found

    Do you have any idea why ?

    Thanks

  • eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass
    miniop wrote on March 6 2015, 4:47 PM: »

    eadwyn thanks !!

    i have a problem when i run the python i get this error :

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
    Traceback (most recent call last):
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 227, in <module>
        indexer = thumb[thumb.index('/') + 1:thumb.index('_')]
    ValueError: substring not found

    Do you have any idea why ?

    Thanks

    Thanks for being the first to try this out and test it :)

    It appears to be an issue with parsing the image metadata location.  In the next release I'll add some better logic to handle cases where we can't parse it, but could you try the following to help me figure out if there is a different format I need to support?

    After line 225 (thumb = movie[1]) add the following line:

    print thumb

    Then when it fails again, please copy the error and the line previous to the error.

    Thanks!

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass
    edited March 2015

    hi easwyn

    I have changed as you requested :

    thumb = movie[1]
    print thumb

    thumb = thumb[11:len(thumb)]
     

    and this is the result :

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 226
        thumb = thumb[11:len(thumb)]
        ^
    IndentationError: unexpected indent

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass

    i have add a ; at the end of the print thumb; and here is the result :

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
    http://image.tmdb.org/t/p/original/cdyJ6GQbKQAL0v2iiKi1PL2TqUn.jpg
    Traceback (most recent call last):
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 228, in <module>
        indexer = thumb[thumb.index('/') + 1:thumb.index('_')]
    ValueError: substring not found

  • eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass
    edited March 2015

    Ok, so it looks like it's failing on an external image (which I don't have in my library).  I'll create something shortly to address that.

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
    http://image.tmdb.org/t/p/original/cdyJ6GQbKQAL0v2iiKi1PL2TqUn.jpg
    Traceback (most recent call last):
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 228, in <module>
        indexer = thumb[thumb.index('/') + 1:thumb.index('_')]
    ValueError: substring not found

  • eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass
    miniop wrote on March 6 2015, 5:34 PM: »

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
    http://image.tmdb.org/t/p/original/cdyJ6GQbKQAL0v2iiKi1PL2TqUn.jpg
    Traceback (most recent call last):
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 228, in <module>
        indexer = thumb[thumb.index('/') + 1:thumb.index('_')]
    ValueError: substring not found

    It was an issue with the external link.  I've now added support for external links, before I push the change to git could you test it for me?

    [attachment=45807:plexEmail.zip]

    Thanks for your help!

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass

    thanks !

    now i am getting another error :

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
    Traceback (most recent call last):
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 250, in <module>
        emailMovies += '<p class="lead">Runtime: ' + str(movie[1] // 100
    0 // 60) + ' minutes</p>'
    TypeError: unsupported operand type(s) for //: 'NoneType' and 'int'

  • eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass
    miniop wrote on March 6 2015, 6:31 PM: »

    thanks !

    now i am getting another error :

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
    Traceback (most recent call last):
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 250, in <module>
        emailMovies += '<p class="lead">Runtime: ' + str(movie[1] // 100
    0 // 60) + ' minutes</p>'
    TypeError: unsupported operand type(s) for //: 'NoneType' and 'int'

    Obviously it's not the cleanest code, so thanks for your help on this!  Fixed this error here: [attachment=45809:plexEmail.zip]

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass

    :)

    getting another error now :

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
    Traceback (most recent call last):
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 425, in <module>
        thumb = season[1]
    KeyError: 'season_thumb_url'

  • eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass
    miniop wrote on March 6 2015, 6:53 PM: »

    :)

    getting another error now :

    C:\PlexEmail-0.1.2\scripts>plexEmail.py
    Traceback (most recent call last):
      File "C:\PlexEmail-0.1.2\scripts\plexEmail.py", line 425, in <module>
        thumb = season[1]
    KeyError: 'season_thumb_url'

    Try this one: [attachment=45818:plexEmail.zip]

    In the second to last section of the code, so almost there :)

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass
    edited March 2015

    perfect !!!!!!!! its working now.

    The website is created still i havent got the email but i might have a problem :P

    one question how i can add multiple emails ? seperate with ; or , or | ?

    Thanks for the help !!!

  • eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass
    edited March 2015

    Awesome!  I've only tested it using gmail, so if you are using a different provider let me know and I can see if I can get it to work.

    Thanks for helping squash some bugs.

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass

    i have a domain and i have add my domain mail information. At the end the python is saying that the mail sent but still not getting any email.

    just checked the incoming of my mail and the mails returned :

    This message was created automatically by mail delivery software.

    A message that you sent could not be delivered to one or more of its
    recipients. This is a permanent error. The following address(es) failed:

      dimiboyy@hotmail.com
        SMTP error from remote mail server after end of data:
        552 5.7.0 Number of MIME parts exceeds maximum permitted

    I will check further if the problem is at my end of anything at the script

  • eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass

    It sounds like it is an issue with too many images being sent.  I can add an option to use the images from the website instead of attaching them to the email to help alleviate that.

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass

    thats would be great!!

  • eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass

    Added the option in the config file: email_use_web_images

    https://github.com/jakewaldron/PlexEmail/archive/v0.1.4.zip

    Includes updated plexEmail.py and config.conf

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass

    now its strange.

    Mail is sent succesful.

    In the inbox there is not return email, as before, but yet i havent received the email.

  • eadwyneadwyn Members, Plex Pass Posts: 227 Plex Pass

    Have you checked the spam folder?

  • miniopminiop Members, Plex Pass Posts: 238 Plex Pass

    after 20min it was delivered fine !!!

    Thanks !

    one problem is with the email with utf8 characters it is displayed as N#ON7N= ON1N9N=N/N1 B+N'ONN,ON;O ON7

    Checking the email through outlook it looks good but thourgh iphone/mobile the layout isnt very nice but the utf8 text are displayed fine

«13456743
Sign In or Register to comment.