From 6d7285cb515491aa7e8b73a0d59d0adb1a7bd752 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Thu, 19 Dec 2019 14:09:58 -0800 Subject: [PATCH] Check remove first in hide_episode_spoilers.py The default `blur` made it skip the remove option --- utility/hide_episode_spoilers.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/utility/hide_episode_spoilers.py b/utility/hide_episode_spoilers.py index 7df4d7c..a477704 100644 --- a/utility/hide_episode_spoilers.py +++ b/utility/hide_episode_spoilers.py @@ -68,7 +68,22 @@ if __name__ == "__main__": parser.add_argument('--remove', action='store_true') opts = parser.parse_args() - if opts.image: + if opts.remove: + # File path to episode artwork using the same episode file name without extension + episode_path = os.path.dirname(opts.file) + episode_filename = os.path.splitext(os.path.basename(opts.file))[0] + + # Find image files with the same name as the episode + for filename in os.listdir(episode_path): + if filename.startswith(episode_filename) and filename.endswith(('.jpg', '.png')): + # Delete the episode artwork image file + os.remove(os.path.join(episode_path, filename)) + + # Refresh metadata for the TV show + plex = PlexServer(PLEX_URL, PLEX_TOKEN) + plex.fetchItem(opts.rating_key).show().refresh() + + elif opts.image: # File path to episode artwork using the same episode file name episode_artwork = os.path.splitext(opts.file)[0] + os.path.splitext(opts.image)[1] @@ -93,18 +108,3 @@ if __name__ == "__main__": # Refresh metadata for the TV show plex = PlexServer(PLEX_URL, PLEX_TOKEN) plex.fetchItem(opts.rating_key).show().refresh() - - elif opts.remove: - # File path to episode artwork using the same episode file name without extension - episode_path = os.path.dirname(opts.file) - episode_filename = os.path.splitext(os.path.basename(opts.file))[0] - - # Find image files with the same name as the episode - for filename in os.listdir(episode_path): - if filename.startswith(episode_filename) and filename.endswith(('.jpg', '.png')): - # Delete the episode artwork image file - os.remove(os.path.join(episode_path, filename)) - - # Refresh metadata for the TV show - plex = PlexServer(PLEX_URL, PLEX_TOKEN) - plex.fetchItem(opts.rating_key).show().refresh()