[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:
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

@ -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

@ -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):

Loading…
Cancel
Save