Skip to content

Commit

Permalink
Watched: Remove deepcopy due to performance
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi311 committed Jan 6, 2024
1 parent 01fc13c commit f80c20d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def get_user_library_watched_show(show):
)
}


return show_guids, episode_guids
except Exception:
return {}, {}
Expand Down
15 changes: 9 additions & 6 deletions src/watched.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f80c20d

Please sign in to comment.