diff --git a/VERSION b/VERSION index e1b7b862..11ca5376 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.0-develop35 +1.17.0-develop36 diff --git a/modules/cache.py b/modules/cache.py index 0da17487..aa6880f6 100644 --- a/modules/cache.py +++ b/modules/cache.py @@ -711,7 +711,7 @@ class Cache: with closing(connection.cursor()) as cursor: cursor.execute(f"SELECT * FROM {table_name} WHERE rating_key = ?", (rating_key,)) row = cursor.fetchone() - if row and row["location"]: + if row: return row["location"], row["compare"], row["overlay"] return None, None, None diff --git a/modules/library.py b/modules/library.py index 7ae5e244..4722202b 100644 --- a/modules/library.py +++ b/modules/library.py @@ -149,18 +149,18 @@ class Library(ABC): except Failed as e: logger.error(e) - def upload_images(self, item, poster=None, background=None): - image = None - image_compare = None + def upload_images(self, item, poster=None, background=None, overlay=False): poster_uploaded = False - if self.config.Cache: - image, image_compare, _ = self.config.Cache.query_image_map(item.ratingKey, self.image_table_name) - if poster is not None: try: - if image_compare and str(poster.compare) != str(image_compare): - image = None - if image is None or image != item.thumb: + image_compare = None + if self.config.Cache: + _, image_compare, _ = self.config.Cache.query_image_map(item.ratingKey, self.image_table_name) + if not image_compare or str(poster.compare) != str(image_compare): + test = [la.tag for la in self.item_labels(item)] + if overlay and "Overlay" in test: + item.removeLabel("Overlay") + item.saveEdits() self._upload_image(item, poster) poster_uploaded = True logger.info(f"Detail: {poster.attribute} updated {poster.message}") @@ -173,12 +173,10 @@ class Library(ABC): background_uploaded = False if background is not None: try: - image = None + image_compare = None if self.config.Cache: - image, image_compare, _ = self.config.Cache.query_image_map(item.ratingKey, f"{self.image_table_name}_backgrounds") - if str(background.compare) != str(image_compare): - image = None - if image is None or image != item.art: + _, image_compare, _ = self.config.Cache.query_image_map(item.ratingKey, f"{self.image_table_name}_backgrounds") + if not image_compare or str(background.compare) != str(image_compare): self._upload_image(item, background) background_uploaded = True logger.info(f"Detail: {background.attribute} updated {background.message}") @@ -187,12 +185,11 @@ class Library(ABC): except Failed: logger.stacktrace() logger.error(f"Detail: {background.attribute} failed to update {background.message}") - if self.config.Cache: if poster_uploaded: - self.config.Cache.update_image_map(item.ratingKey, self.image_table_name, item.thumb, poster.compare if poster else "") + self.config.Cache.update_image_map(item.ratingKey, self.image_table_name, "", poster.compare if poster else "") if background_uploaded: - self.config.Cache.update_image_map(item.ratingKey, f"{self.image_table_name}_backgrounds", item.art, background.compare) + self.config.Cache.update_image_map(item.ratingKey, f"{self.image_table_name}_backgrounds", "", background.compare) return poster_uploaded, background_uploaded @@ -223,6 +220,10 @@ class Library(ABC): def edit_tags(self, attr, obj, add_tags=None, remove_tags=None, sync_tags=None, do_print=True): pass + @abstractmethod + def item_labels(self, item): + pass + @abstractmethod def get_all(self, collection_level=None, load=False): pass diff --git a/modules/plex.py b/modules/plex.py index 8abc1425..1414327e 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -928,7 +928,7 @@ class Plex(Library): background = util.pick_image(title, backgrounds, self.prioritize_assets, self.download_url_assets, asset_location, is_poster=False, image_name=f"{image_name}_background" if image_name else image_name) if poster or background: - self.upload_images(item, poster=poster, background=background) + self.upload_images(item, poster=poster, background=background, overlay=True) return asset_location, folder_name def find_and_upload_assets(self, item):