add fucntion to get viewings before a date

This commit is contained in:
Sarah 2022-12-16 21:15:23 +00:00
parent 41860df682
commit 72c4e5864e
1 changed files with 14 additions and 1 deletions

View File

@ -1,6 +1,7 @@
from collections import Counter
from concurrent.futures import ThreadPoolExecutor
import csv
from datetime import datetime
from imdb_utils import IMDbUtils
from bookstack import Bookstack
@ -33,7 +34,9 @@ def get_vcinema_viewings(token_id, token_secret, viewings_csv=None, combine_repe
if combine_repeat_viewings:
for viewing in viewings:
viewing['viewings'] = [
{'date_watched': viewing['date_watched'], 'season': viewing['season'], 'rating': viewing['rating']}]
{'date_watched': datetime.strptime(viewing['date_watched'], "%Y-%m-%d"),
'season': viewing['season'],
'rating': viewing['rating']}]
viewing.pop('date_watched')
viewing.pop('season')
viewing.pop('rating')
@ -117,6 +120,16 @@ def filter_viewings(viewings, filter_field):
return viewings_filtered
def get_viewings_before_date(viewings, date):
viewings_before_date = []
for viewing in viewings:
if all(view_date["date_watched"] < date for view_date in viewing["viewings"]):
viewings_before_date.append(viewing)
return viewings_before_date
def get_film_list(films):
film_links = []