From 9283cbd313a6dbebdd94838cf6e3b0e835770197 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Mon, 6 Feb 2023 15:34:40 -0500 Subject: [PATCH] [59] fix reapply overlays --- VERSION | 2 +- modules/library.py | 8 +++----- modules/meta.py | 8 +++++--- modules/overlays.py | 2 +- modules/plex.py | 2 +- modules/trakt.py | 22 ++++++++++++---------- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/VERSION b/VERSION index 085d464d..7ebaf2df 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.3-develop58 +1.18.3-develop59 diff --git a/modules/library.py b/modules/library.py index 340be284..438c0c9d 100644 --- a/modules/library.py +++ b/modules/library.py @@ -167,12 +167,10 @@ class Library(ABC): 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): - if hasattr(item, "labels"): - test = [la.tag for la in self.item_labels(item)] - if overlay and "Overlay" in test: + if overlay: + self.reload(item, force=True) + if overlay and "Overlay" in [la.tag for la in self.item_labels(item)]: item.removeLabel("Overlay") - if isinstance(item._edits, dict): - item.saveEdits() self._upload_image(item, poster) poster_uploaded = True logger.info(f"Detail: {poster.attribute} updated {poster.message}") diff --git a/modules/meta.py b/modules/meta.py index a07985af..ea9ab470 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -1210,7 +1210,7 @@ class MetadataFile(DataFile): nonlocal updated if updated: try: - current_item.saveEdits() + #current_item.saveEdits() logger.info(f"{description} Details Update Successful") except BadRequest: logger.error(f"{description} Details Update Failed") @@ -1256,7 +1256,7 @@ class MetadataFile(DataFile): summary = tmdb_item.overview genres = tmdb_item.genres - item.batchEdits() + #item.batchEdits() if title: add_edit("title", item, meta, methods, value=title) add_edit("sort_title", item, meta, methods, key="titleSort") @@ -1279,7 +1279,7 @@ class MetadataFile(DataFile): if self.library.type in util.advance_tags_to_edit: advance_edits = {} - prefs = [p.id for p in item.preferences()] + prefs = None for advance_edit in util.advance_tags_to_edit[self.library.type]: if advance_edit in methods: if advance_edit in ["metadata_language", "use_original_title"] and self.library.agent not in plex.new_plex_agents: @@ -1287,6 +1287,8 @@ class MetadataFile(DataFile): elif meta[methods[advance_edit]]: ad_key, options = plex.item_advance_keys[f"item_{advance_edit}"] method_data = str(meta[methods[advance_edit]]).lower() + if prefs is None: + prefs = [p.id for p in item.preferences()] if method_data not in options: logger.error(f"Metadata Error: {meta[methods[advance_edit]]} {advance_edit} attribute invalid") elif ad_key in prefs and getattr(item, ad_key) != options[method_data]: diff --git a/modules/overlays.py b/modules/overlays.py index 587319df..55f41b27 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -79,7 +79,7 @@ class Overlays: poster = None if self.config.Cache: image, image_compare, overlay_compare = self.config.Cache.query_image_map(item.ratingKey, f"{self.library.image_table_name}_overlays") - self.library.reload(item) + self.library.reload(item, force=True) overlay_compare = [] if overlay_compare is None else util.get_list(overlay_compare, split="|") has_overlay = any([item_tag.tag.lower() == "overlay" for item_tag in self.library.item_labels(item)]) diff --git a/modules/plex.py b/modules/plex.py index a23aa0d2..8a20d125 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -611,7 +611,7 @@ class Plex(Library): return self.config.TMDb.get_episode(tmdb_id, item.seasonNumber, item.episodeNumber).still_url def item_posters(self, item, providers=None): - if not providers: + if providers is None: providers = ["plex", "tmdb"] image_url = None for provider in providers: diff --git a/modules/trakt.py b/modules/trakt.py index 72a1eed5..9eb81639 100644 --- a/modules/trakt.py +++ b/modules/trakt.py @@ -254,7 +254,7 @@ class Trakt: except Failed: raise Failed(f"Trakt Error: List {data} not found") - def _parse(self, items, typeless=False, item_type=None, trakt_ids=False): + def _parse(self, items, typeless=False, item_type=None, trakt_ids=False, ignore_other=False): ids = [] for item in items: if typeless: @@ -268,6 +268,8 @@ class Trakt: current_type = item["type"] else: continue + if current_type in ["person", "list"] and ignore_other: + continue id_type, id_display = id_types[current_type] if id_type in data["ids"] and data["ids"][id_type]: final_id = data["ids"][id_type] @@ -373,7 +375,7 @@ class Trakt: def build_user_url(self, user, name): return f"{base_url.replace('api.', '')}/users/{user}/lists/{name}" - def _list(self, data, urlparse=True, trakt_ids=False, fail=True): + def _list(self, data, urlparse=True, trakt_ids=False, fail=True, ignore_other=False): try: url = requests.utils.urlparse(data).path if urlparse else f"/users/me/lists/{data}" items = self._request(f"{url}/items") @@ -384,9 +386,9 @@ class Trakt: raise Failed(f"Trakt Error: List {data} is empty") else: return [] - return self._parse(items, trakt_ids=trakt_ids) + return self._parse(items, trakt_ids=trakt_ids, ignore_other=ignore_other) - def _userlist(self, list_type, user, is_movie, sort_by=None): + def _userlist(self, list_type, user, is_movie, sort_by=None, ignore_other=False): try: url_end = "movies" if is_movie else "shows" if sort_by: @@ -396,7 +398,7 @@ class Trakt: raise Failed(f"Trakt Error: User {user} not found") if len(items) == 0: raise Failed(f"Trakt Error: {user}'s {list_type.capitalize()} is empty") - return self._parse(items, item_type="movie" if is_movie else "show") + return self._parse(items, item_type="movie" if is_movie else "show", ignore_other=ignore_other) def _recommendations(self, limit, is_movie): media_type = "Movie" if is_movie else "Show" @@ -408,10 +410,10 @@ class Trakt: raise Failed(f"Trakt Error: no {media_type} Recommendations were found") return self._parse(items, typeless=True, item_type="movie" if is_movie else "show") - def _charts(self, chart_type, is_movie, params, time_period=None): + def _charts(self, chart_type, is_movie, params, time_period=None, ignore_other=False): chart_url = f"{chart_type}/{time_period}" if time_period else chart_type items = self._request(f"/{'movies' if is_movie else 'shows'}/{chart_url}", params=params) - return self._parse(items, typeless=chart_type == "popular", item_type="movie" if is_movie else "show") + return self._parse(items, typeless=chart_type == "popular", item_type="movie" if is_movie else "show", ignore_other=ignore_other) def get_people(self, data): return {str(i[0][0]): i[0][1] for i in self._list(data) if i[1] == "tmdb_person"} @@ -491,7 +493,7 @@ class Trakt: media_type = "Movie" if is_movie else "Show" if method == "trakt_list": logger.info(f"Processing {pretty}: {data}") - return self._list(data) + return self._list(data, ignore_other=True) elif method == "trakt_recommendations": logger.info(f"Processing {pretty}: {data} {media_type}{'' if data == 1 else 's'}") return self._recommendations(data, is_movie) @@ -504,10 +506,10 @@ class Trakt: logger.info(f"{attr:>22}: {','.join(data[attr]) if isinstance(data[attr], list) else data[attr]}") values = [status_translation[v] for v in data[attr]] if attr == "status" else data[attr] params[attr] = ",".join(values) if isinstance(values, list) else values - return self._charts(data["chart"], is_movie, params, time_period=data["time_period"]) + return self._charts(data["chart"], is_movie, params, time_period=data["time_period"], ignore_other=True) elif method == "trakt_userlist": logger.info(f"Processing {pretty} {media_type}s from {data['user']}'s {data['userlist'].capitalize()}") - return self._userlist(data["userlist"], data["user"], is_movie, sort_by=data["sort_by"]) + return self._userlist(data["userlist"], data["user"], is_movie, sort_by=data["sort_by"], ignore_other=True) elif method == "trakt_boxoffice": logger.info(f"Processing {pretty}: {data} {media_type}{'' if data == 1 else 's'}") return self._charts("boxoffice", is_movie, {"limit": data})