From 323f00612835b55ff5187234b38bb7e49837f696 Mon Sep 17 00:00:00 2001 From: jakewaldron Date: Fri, 13 Mar 2015 16:09:20 -0700 Subject: [PATCH] New Features Can now set days, hours and minutes and use all fields in the search. Can now filter categories Ease of Use updates --- README.md | 30 ++++++++------------ scripts/config.conf | 15 +++++++--- scripts/plexEmail.py | 67 +++++++++++++++++++++++++++++--------------- 3 files changed, 67 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index d3573c3..1eef704 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,17 @@ This script aggregates all new TV and movie releases for the past x days and wri ## Supported Environments * Windows - Tested * Linux - Tested -* Mac +* Mac - Tested ## Supported Email Protocols * SMTP ## Prerequisites -1. Python 2.7 - 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 - http://www.sqlite.org/2015/sqlite-dll-win32-x86-3080803.zip (Put this into the DLLs folder of the Python installation) -3. If web reports are wanted, a web server (i.e. Wamp, Apache, etc.) +1. Python 2.7 - Windows: 32 bit - https://www.python.org/ftp/python/2.7.9/python-2.7.9.msi +2. Windows - 32 bit DLL for SQLite version 3.8.8.3 - http://www.sqlite.org/2015/sqlite-dll-win32-x86-3080803.zip (Put this into the DLLs folder of the Python installation) +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 (i.e. Wamp, Apache, etc.) ## Installation (Windows) @@ -88,19 +89,6 @@ python plexEmail.py -c C:\files\plexEmailWeekly.conf The config file is in the scripts folder. Before first run of the script, please update this file with your information. -####Required Fields to Update: - -* plex_data_folder -* web_folder -* web_domain -* web_path -* email_to -* email_from -* email_smtp_address (gmail default) -* email_smtp_port -* email_username -* email_password - ####Field Explanations: #####Folder Paths @@ -110,8 +98,8 @@ The config file is in the scripts folder. Before first run of the script, pleas #####General * date_format - Format to use for the date * date_days_back_to_search - Number of days to search backwards -* date_use_hours - Search back y hours instead of days (useful for 24 hours reports) * date_hours_back_to_search - Number of hours to search backwards +* date_minutes_back_to_search - Number of minutes to search backwards #####Web * web_enabled - Enable the creation of the web page @@ -141,6 +129,12 @@ The config file is in the scripts folder. Before first run of the script, pleas * 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 + #####Messages * msg_email_teaser - Teaser text on the email * msg_web_title - Title of the webpage diff --git a/scripts/config.conf b/scripts/config.conf index 5efd8cf..a59295c 100644 --- a/scripts/config.conf +++ b/scripts/config.conf @@ -1,6 +1,7 @@ ##Folder Paths -# Windows Example: 'E:\\Library\\Plex\\' -# Linux/Mac Example: '/var/lib/plexmediaserver/Library/Application Support/' +# 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 = '' # Windows Example: 'C:\\wamp\\www\\' # Linux/Mac Example: '/var/www/' @@ -9,8 +10,8 @@ web_folder = '' ##General date_format = '%m/%d/%y' date_days_back_to_search = 7 -date_use_hours = False -date_hours_back_to_search = 24 +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/ @@ -41,6 +42,12 @@ email_password = '' email_use_web_images = True email_skip_if_no_additions = False +##Filtering +filter_show_movies = True +filter_show_shows = True +filter_show_seasons = True +filter_show_episodes = True + ##Messages msg_email_teaser = 'Check out this week\'s releases from Plex: {website} - {past_day} - {current_day}' msg_web_title = 'New Plex Releases' diff --git a/scripts/plexEmail.py b/scripts/plexEmail.py index 05121b4..8d9ab24 100644 --- a/scripts/plexEmail.py +++ b/scripts/plexEmail.py @@ -22,6 +22,21 @@ def replaceConfigTokens(): ## The below code is for backwards compatibility + if ('filter_show_movies' not in config): + config['filter_show_movies'] = True + + if ('filter_show_shows' not in config): + config['filter_show_shows'] = True + + if ('filter_show_seasons' not in config): + config['filter_show_seasons'] = True + + if ('filter_show_episodes' not in config): + config['filter_show_episodes'] = True + + if ('date_minutes_back_to_search' not in config): + config['date_minutes_back_to_search'] = 0 + if ('msg_no_new_content' not in config): config['msg_no_new_content'] = 'There have been no new additions to Plex from {past_day} through {current_day}.' @@ -85,18 +100,18 @@ def replaceConfigTokens(): # The below code is replacing tokens for value in config: if (isinstance(config[value], str)): - if ('date_use_hours' in config and config['date_use_hours']): - config[value] = config[value].replace('{past_day}', str((date.today() - timedelta(hours=config['date_hours_back_to_search'])).strftime(config['date_format']))) - else: - config[value] = config[value].replace('{past_day}', str((date.today() - timedelta(days=config['date_days_back_to_search'])).strftime(config['date_format']))) + config[value] = config[value].replace('{past_day}', str((date.today() - timedelta(days=config['date_days_back_to_search'], hours=config['date_hours_back_to_search'], minutes=config['date_minutes_back_to_search'])).strftime(config['date_format']))) config[value] = config[value].replace('{current_day}', str(date.today().strftime(config['date_format']))) config[value] = config[value].replace('{website}', config['web_domain'] + config['web_path']) config[value] = config[value].replace('{path_sep}', os.path.sep) - if (config['plex_data_folder'] and config['plex_data_folder'].rfind(os.path.sep) < len(config['plex_data_folder']) - len(os.path.sep)): + if (config['plex_data_folder'].rfind(os.path.sep) < len(config['plex_data_folder']) - len(os.path.sep)): config['plex_data_folder'] = config['plex_data_folder'] + os.path.sep - if (config['web_folder'] and config['web_folder'].rfind(os.path.sep) < len(config['web_folder']) - len(os.path.sep)): + if (config['plex_data_folder'].find('Plex Media Server') >= 0): + config['plex_data_folder'] = config['plex_data_folder'][0:config['plex_data_folder'].find('Plex Media Server')] + + if (config['web_folder'].rfind(os.path.sep) < len(config['web_folder']) - len(os.path.sep)): config['web_folder'] = config['web_folder'] + os.path.sep def deleteImages(): @@ -304,13 +319,13 @@ def createEmailHTML():
""" - if (movieCount > 0): + if (movieCount > 0 and config['filter_show_movies']): emailText += emailMovies + '
 ' - if (showCount > 0): + if (showCount > 0 and config['filter_show_shows']): emailText += emailTVShows + '
 ' - if (seasonCount > 0): + if (seasonCount > 0 and config['filter_show_seasons']): emailText += emailTVSeasons + '
 ' - if (episodeCount > 0): + if (episodeCount > 0 and config['filter_show_episodes']): emailText += emailTVEpisodes if(not hasNewContent): @@ -396,22 +411,22 @@ def createWebHTML():
 
 ' - if (movieCount > 0 or showCount > 0 or seasonCount > 0 or episodeCount > 0): + if ((movieCount > 0 and config['filter_show_movies']) or (showCount > 0 and config['filter_show_shows']) or (seasonCount > 0 and config['filter_show_seasons']) or (episodeCount > 0 and config['filter_show_episodes'])): hasNewContent = True else: hasNewContent = False