From f80c20d70c0d1f5f3548435b7be4b1ddc13a4daf Mon Sep 17 00:00:00 2001 From: Luigi311 Date: Fri, 5 Jan 2024 23:46:15 -0700 Subject: [PATCH] Watched: Remove deepcopy due to performance --- src/plex.py | 1 - src/watched.py | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plex.py b/src/plex.py index 28a7650..6b14c27 100644 --- a/src/plex.py +++ b/src/plex.py @@ -100,7 +100,6 @@ def get_user_library_watched_show(show): ) } - return show_guids, episode_guids except Exception: return {}, {} diff --git a/src/watched.py b/src/watched.py index 8f76670..23fa2d9 100644 --- a/src/watched.py +++ b/src/watched.py @@ -268,14 +268,17 @@ def filter_episode_watched_list_2_keys_dict( # Find the intersection of the show_indecies and season_indecies lists indecies = list(set(show_indecies) & set(season_indecies)) + filtered_episode_watched_list_2_keys_dict = {} # Create a copy of the dictionary with indecies that match the show and season and none that don't - filtered_episode_watched_list_2_keys_dict = copy.deepcopy( - episode_watched_list_2_keys_dict - ) - for key, value in filtered_episode_watched_list_2_keys_dict.items(): + for key, value in episode_watched_list_2_keys_dict.items(): + if key not in filtered_episode_watched_list_2_keys_dict: + filtered_episode_watched_list_2_keys_dict[key] = [] + for index in range(len(value)): - if index not in indecies: - filtered_episode_watched_list_2_keys_dict[key][index] = None + if index in indecies: + filtered_episode_watched_list_2_keys_dict[key].append(value[index]) + else: + filtered_episode_watched_list_2_keys_dict[key].append(None) return filtered_episode_watched_list_2_keys_dict