diff --git a/vcinema_utils/VCinemaUtils.py b/vcinema_utils/VCinemaUtils.py index 9de968b..523eb57 100644 --- a/vcinema_utils/VCinemaUtils.py +++ b/vcinema_utils/VCinemaUtils.py @@ -36,15 +36,15 @@ def add_imdb_data_to_viewings(viewings, field_name): bar.finish() -def filter_viewings(viewings, pivot_field, remove_duplicates=True): +def filter_viewings(viewings, filter_field, remove_duplicates=True): viewings_filtered = {} for viewing in viewings: - viewing_field = viewing[pivot_field] + viewing_field = viewing[filter_field] 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] else: - viewings_filtered[viewing[pivot_field]] = [viewing] + viewings_filtered[viewing[filter_field]] = [viewing] return viewings_filtered