From c2488400a0b6e3f3be6e5ac71fc010eb408b96d7 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 16 Jun 2022 01:04:50 -0400 Subject: [PATCH] [42] asset updates --- VERSION | 2 +- modules/imdb.py | 2 ++ modules/plex.py | 51 +++++++++++++++++++++++++++++++------------------ 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/VERSION b/VERSION index 61420b25..c4d70fd4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.0-develop41 +1.17.0-develop42 diff --git a/modules/imdb.py b/modules/imdb.py index 6e6597b3..38bf4a24 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -260,6 +260,8 @@ class IMDb: return self.ratings[imdb_id] if imdb_id in self.ratings else None def get_episode_rating(self, imdb_id, season_num, episode_num): + season_num = str(season_num) + episode_num = str(episode_num) if imdb_id not in self.episode_ratings or season_num not in self.episode_ratings[imdb_id] or episode_num not in self.episode_ratings[imdb_id][season_num]: return None return self.episode_ratings[imdb_id][season_num][episode_num] diff --git a/modules/plex.py b/modules/plex.py index b60bb431..dfcc9d35 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -939,6 +939,8 @@ class Plex(Library): return asset_location, folder_name def find_and_upload_assets(self, item, current_labels): + item_dir = None + name = None try: poster, background, item_dir, name = self.find_item_assets(item) if "Overlay" not in current_labels: @@ -948,13 +950,16 @@ class Plex(Library): logger.warning(f"Asset Warning: No poster or background found in the assets folder '{item_dir}'") else: logger.warning(f"Asset Warning: {name} has an Overlay and will be updated when overlays are run") - - if isinstance(item, Show): - missing_seasons = "" - missing_episodes = "" - found_season = False - found_episode = False - for season in self.query(item.seasons): + except Failed as e: + if self.show_missing_assets: + logger.warning(e) + if isinstance(item, Show): + missing_seasons = "" + missing_episodes = "" + found_season = False + found_episode = False + for season in self.query(item.seasons): + try: season_poster, season_background, _, _ = self.find_item_assets(season, item_asset_directory=item_dir, folder_name=name) if season_poster: found_season = True @@ -962,7 +967,11 @@ class Plex(Library): missing_seasons += f"\nMissing Season {season.seasonNumber} Poster" if season_poster or season_background and "Overlay" not in [la.tag for la in self.item_labels(season)]: self.upload_images(season, poster=season_poster, background=season_background) - for episode in self.query(season.episodes): + except Failed as e: + if self.show_missing_assets: + logger.warning(e) + for episode in self.query(season.episodes): + try: if episode.seasonEpisode: episode_poster, episode_background, _, _ = self.find_item_assets(episode, item_asset_directory=item_dir, folder_name=name) if episode_poster or episode_background: @@ -971,12 +980,16 @@ class Plex(Library): self.upload_images(episode, poster=episode_poster, background=episode_background) elif self.show_missing_episode_assets: missing_episodes += f"\nMissing {episode.seasonEpisode.upper()} Title Card" - if (found_season and missing_seasons) or (found_episode and missing_episodes): - logger.info(f"Missing Posters for {item.title}{missing_seasons}{missing_episodes}") - if isinstance(item, Artist): - missing_assets = "" - found_album = False - for album in self.query(item.albums): + except Failed as e: + if self.show_missing_assets: + logger.warning(e) + if (found_season and missing_seasons) or (found_episode and missing_episodes): + logger.info(f"Missing Posters for {item.title}{missing_seasons}{missing_episodes}") + if isinstance(item, Artist): + missing_assets = "" + found_album = False + for album in self.query(item.albums): + try: album_poster, album_background, _, _ = self.find_item_assets(album, item_asset_directory=item_dir, folder_name=name) if album_poster or album_background: found_album = True @@ -984,11 +997,11 @@ class Plex(Library): missing_assets += f"\nMissing Album {album.title} Poster" if album_poster or album_background: self.upload_images(album, poster=album_poster, background=album_background) - if self.show_missing_season_assets and found_album and missing_assets: - logger.info(f"Missing Album Posters for {item.title}{missing_assets}") - except Failed as e: - if self.show_missing_assets: - logger.warning(e) + except Failed as e: + if self.show_missing_assets: + logger.warning(e) + if self.show_missing_season_assets and found_album and missing_assets: + logger.info(f"Missing Album Posters for {item.title}{missing_assets}") def find_item_assets(self, item, item_asset_directory=None, asset_directory=None, folder_name=None): poster = None