[36] fix overlays uploads

pull/935/head
meisnate12 3 years ago
parent bd89058ceb
commit cf77fcfa61

@ -1 +1 @@
1.17.0-develop35 1.17.0-develop36

@ -711,7 +711,7 @@ class Cache:
with closing(connection.cursor()) as cursor: with closing(connection.cursor()) as cursor:
cursor.execute(f"SELECT * FROM {table_name} WHERE rating_key = ?", (rating_key,)) cursor.execute(f"SELECT * FROM {table_name} WHERE rating_key = ?", (rating_key,))
row = cursor.fetchone() row = cursor.fetchone()
if row and row["location"]: if row:
return row["location"], row["compare"], row["overlay"] return row["location"], row["compare"], row["overlay"]
return None, None, None return None, None, None

@ -149,18 +149,18 @@ class Library(ABC):
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)
def upload_images(self, item, poster=None, background=None): def upload_images(self, item, poster=None, background=None, overlay=False):
image = None
image_compare = None
poster_uploaded = 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: if poster is not None:
try: try:
if image_compare and str(poster.compare) != str(image_compare): image_compare = None
image = None if self.config.Cache:
if image is None or image != item.thumb: _, 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) self._upload_image(item, poster)
poster_uploaded = True poster_uploaded = True
logger.info(f"Detail: {poster.attribute} updated {poster.message}") logger.info(f"Detail: {poster.attribute} updated {poster.message}")
@ -173,12 +173,10 @@ class Library(ABC):
background_uploaded = False background_uploaded = False
if background is not None: if background is not None:
try: try:
image = None image_compare = None
if self.config.Cache: if self.config.Cache:
image, image_compare, _ = self.config.Cache.query_image_map(item.ratingKey, f"{self.image_table_name}_backgrounds") _, image_compare, _ = self.config.Cache.query_image_map(item.ratingKey, f"{self.image_table_name}_backgrounds")
if str(background.compare) != str(image_compare): if not image_compare or str(background.compare) != str(image_compare):
image = None
if image is None or image != item.art:
self._upload_image(item, background) self._upload_image(item, background)
background_uploaded = True background_uploaded = True
logger.info(f"Detail: {background.attribute} updated {background.message}") logger.info(f"Detail: {background.attribute} updated {background.message}")
@ -187,12 +185,11 @@ class Library(ABC):
except Failed: except Failed:
logger.stacktrace() logger.stacktrace()
logger.error(f"Detail: {background.attribute} failed to update {background.message}") logger.error(f"Detail: {background.attribute} failed to update {background.message}")
if self.config.Cache: if self.config.Cache:
if poster_uploaded: 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: 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 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): def edit_tags(self, attr, obj, add_tags=None, remove_tags=None, sync_tags=None, do_print=True):
pass pass
@abstractmethod
def item_labels(self, item):
pass
@abstractmethod @abstractmethod
def get_all(self, collection_level=None, load=False): def get_all(self, collection_level=None, load=False):
pass pass

@ -928,7 +928,7 @@ class Plex(Library):
background = util.pick_image(title, backgrounds, self.prioritize_assets, self.download_url_assets, asset_location, 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) is_poster=False, image_name=f"{image_name}_background" if image_name else image_name)
if poster or background: 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 return asset_location, folder_name
def find_and_upload_assets(self, item): def find_and_upload_assets(self, item):

Loading…
Cancel
Save