rename var

This commit is contained in:
Sarah 2022-02-20 21:36:53 +00:00
parent 679d1429f3
commit ab098dda0d
1 changed files with 4 additions and 4 deletions

View File

@ -36,15 +36,15 @@ def add_imdb_data_to_viewings(viewings, field_name):
bar.finish() bar.finish()
def filter_viewings(viewings, pivot_field, remove_duplicates=True): def filter_viewings(viewings, filter_field, remove_duplicates=True):
viewings_filtered = {} viewings_filtered = {}
for viewing in viewings: for viewing in viewings:
viewing_field = viewing[pivot_field] viewing_field = viewing[filter_field]
if viewing_field in viewings_filtered.keys(): if viewing_field in viewings_filtered.keys():
if not remove_duplicates or (remove_duplicates and not any(x['imdb_id'] == viewing['imdb_id'] for x in viewings_filtered[viewing_field])): if not remove_duplicates or not any(x['imdb_id'] == viewing['imdb_id'] for x in viewings_filtered[viewing_field]):
viewings_filtered[viewing_field] += [viewing] viewings_filtered[viewing_field] += [viewing]
else: else:
viewings_filtered[viewing[pivot_field]] = [viewing] viewings_filtered[viewing[filter_field]] = [viewing]
return viewings_filtered return viewings_filtered