From edc7781bd8bc8db93b320f87fa1a063dbf92335f Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 1 Feb 2023 15:15:25 -0500 Subject: [PATCH] [51] remove old original posters if an asset is found --- VERSION | 2 +- modules/overlays.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 8254e5c1..c2ccce99 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.3-develop50 +1.18.3-develop51 diff --git a/modules/overlays.py b/modules/overlays.py index f2fea6b2..9a428ec6 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -155,6 +155,10 @@ class Overlays: if poster: if image_compare and str(poster.compare) != str(image_compare): changed_image = True + if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")): + os.remove(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")) + if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")): + os.remove(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")) elif has_overlay: if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")): has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png") @@ -530,13 +534,11 @@ class Overlays: except Failed: poster = None is_url = False - original = None poster_location = None if poster: poster_location = poster.location elif any([os.path.exists(loc) for loc in locations]): - original = next((loc for loc in locations if os.path.exists(loc))) - poster_location = original + poster_location = next((loc for loc in locations if os.path.exists(loc))) if not poster_location: is_url = True try: @@ -546,7 +548,8 @@ class Overlays: if poster_location: self.library.upload_poster(item, poster_location, url=is_url) self.library.edit_tags("label", item, remove_tags=[label], do_print=False) - if original: - os.remove(original) + for loc in locations: + if os.path.exists(loc): + os.remove(loc) else: logger.error(f"No Poster found to restore for {item_title}")