Skip to content

Commit

Permalink
Merge pull request #151 from luigi311/dev
Browse files Browse the repository at this point in the history
Return empty if season/show are missing from episode_watched_list
  • Loading branch information
luigi311 authored Feb 13, 2024
2 parents 86b30e1 + 84899ae commit 62509f1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/watched.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ def get_movie_index_in_dict(movie, movies_watched_list_2_keys_dict):
def filter_episode_watched_list_2_keys_dict(
episode_watched_list_2_keys_dict, show_key_dict, season
):
# If the episode_watched_list_2_keys_dict dictionary is empty, missing season or show then return an empty dictionary
if (
len(episode_watched_list_2_keys_dict) == 0
or "season" not in episode_watched_list_2_keys_dict.keys()
or "show" not in episode_watched_list_2_keys_dict.keys()
):
return {}

# Filter the episode_watched_list_2_keys_dict dictionary to only include values for the correct show and season
filtered_episode_watched_list_2_keys_dict = {}
show_indecies = []
Expand Down Expand Up @@ -268,7 +276,10 @@ 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 = {}
# If there are no indecies that match the show and season, return an empty dictionary
if len(indecies) == 0:
return {}

# Create a copy of the dictionary with indecies that match the show and season and none that don't
for key, value in episode_watched_list_2_keys_dict.items():
if key not in filtered_episode_watched_list_2_keys_dict:
Expand Down

0 comments on commit 62509f1

Please sign in to comment.