From 30905e514f26d309ac1b1fd6ebb64eacf9e7f868 Mon Sep 17 00:00:00 2001 From: Nicholas Cotton Date: Fri, 9 May 2025 10:49:50 -0400 Subject: [PATCH 1/3] Added argument 'hideTitle' which changes the name of the episode to 'Aired on Month Day, Year' in the format 'May 99, 2025'. This is necessary for shows like Jeopardy where the title includes the names of the contestants, which tells you who won the previous game. --- utility/hide_episode_spoilers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utility/hide_episode_spoilers.py b/utility/hide_episode_spoilers.py index 0d800e1..211fb6b 100644 --- a/utility/hide_episode_spoilers.py +++ b/utility/hide_episode_spoilers.py @@ -36,6 +36,7 @@ import os import requests import shutil from plexapi.server import PlexServer +from datetime import datetime PLEX_URL = '' PLEX_TOKEN = '' @@ -45,7 +46,7 @@ PLEX_URL = os.getenv('PLEX_URL', PLEX_URL) PLEX_TOKEN = os.getenv('PLEX_TOKEN', PLEX_TOKEN) -def modify_episode_artwork(plex, rating_key, image=None, blur=None, summary_prefix=None, remove=False, upload=False): +def modify_episode_artwork(plex, rating_key, image=None, blur=None, summary_prefix=None, remove=False, upload=False, hideTitle=False): item = plex.fetchItem(rating_key) if item.type == 'show': @@ -115,7 +116,9 @@ def modify_episode_artwork(plex, rating_key, image=None, blur=None, summary_pref if summary_prefix and not episode.summary.startswith(summary_prefix): # Use a zero-width space (\u200b) for blank lines episode.editSummary(summary_prefix + '\n\u200b\n' + episode.summary) - + if hideTitle: + episode_title = episode.originallyAvailableAt.strftime("%B %d, %Y") + episode.editTitle('Aired ' + episode_title) # Refresh metadata for the episode episode.refresh() @@ -128,6 +131,7 @@ if __name__ == "__main__": parser.add_argument('--summary_prefix', nargs='?', const='** SPOILERS **') parser.add_argument('--remove', action='store_true') parser.add_argument('--upload', action='store_true') + parser.add_argument('-hideTitle', action='store_true') opts = parser.parse_args() plex = PlexServer(PLEX_URL, PLEX_TOKEN) From 0bf6d03c88aa85bc5c697ce1af74246d2ab73493 Mon Sep 17 00:00:00 2001 From: Nicholas Cotton Date: Tue, 13 May 2025 14:43:48 -0400 Subject: [PATCH 2/3] Added usage instructions in top comments, fixed typo. --- utility/hide_episode_spoilers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utility/hide_episode_spoilers.py b/utility/hide_episode_spoilers.py index 211fb6b..91ffd60 100644 --- a/utility/hide_episode_spoilers.py +++ b/utility/hide_episode_spoilers.py @@ -23,6 +23,8 @@ # --rating_key {rating_key} --summary_prefix "** SPOILERS **" # To upload the episode artwork instead of creating a local asset (optional, for when the script cannot access the media folder): # --rating_key {rating_key} --blur 25 --upload +# To replace episode title with "Aired %B %d, %Y (May 13, 2025) (optional, for shows where the title is a spoiler e.g. Jeopardy!) +# --hideTitle # * Watched (optional): # To remove the local asset episode artwork: # --rating_key {rating_key} --remove @@ -131,7 +133,7 @@ if __name__ == "__main__": parser.add_argument('--summary_prefix', nargs='?', const='** SPOILERS **') parser.add_argument('--remove', action='store_true') parser.add_argument('--upload', action='store_true') - parser.add_argument('-hideTitle', action='store_true') + parser.add_argument('--hideTitle', action='store_true') opts = parser.parse_args() plex = PlexServer(PLEX_URL, PLEX_TOKEN) From 255c2ebb2160598ebe5021105a579e0757f3a9a5 Mon Sep 17 00:00:00 2001 From: Nicholas Cotton Date: Wed, 14 May 2025 08:56:56 -0400 Subject: [PATCH 3/3] Add support for removing the hideTitle and reverting to the original title @line 84. --- utility/hide_episode_spoilers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utility/hide_episode_spoilers.py b/utility/hide_episode_spoilers.py index 91ffd60..254b6d4 100644 --- a/utility/hide_episode_spoilers.py +++ b/utility/hide_episode_spoilers.py @@ -79,8 +79,9 @@ def modify_episode_artwork(plex, rating_key, image=None, blur=None, summary_pref # Delete the episode artwork image file os.remove(os.path.join(episode_folder, filename)) - # Unlock the summary so it will get updated on refresh + # Unlock the summary & title so they will get updated on refresh episode.editSummary(episode.summary, locked=False) + episode.editTitle(episode.title, locked=False) continue if image: