add season and rating to viewing list for each film
This commit is contained in:
parent
7af6968dab
commit
93033b3f1c
@ -29,6 +29,12 @@ def get_vcinema_viewings(token_id, token_secret, combine_repeat_viewings=True):
|
|||||||
headers = viewings_csv_rows.pop(0).split(",")
|
headers = viewings_csv_rows.pop(0).split(",")
|
||||||
viewings = [dict(zip(headers, row.split(","))) for row in viewings_csv_rows]
|
viewings = [dict(zip(headers, row.split(","))) for row in viewings_csv_rows]
|
||||||
|
|
||||||
|
for viewing in viewings:
|
||||||
|
viewing['viewings'] = [{'date_watched': viewing['date_watched'], 'season': viewing['season'], 'rating': viewing['rating']}]
|
||||||
|
viewing.pop('date_watched')
|
||||||
|
viewing.pop('season')
|
||||||
|
viewing.pop('rating')
|
||||||
|
|
||||||
if combine_repeat_viewings:
|
if combine_repeat_viewings:
|
||||||
watch_counts = Counter([x['imdb_id'] for x in viewings])
|
watch_counts = Counter([x['imdb_id'] for x in viewings])
|
||||||
repeat_watches = [k for k, v in watch_counts.items() if v > 1]
|
repeat_watches = [k for k, v in watch_counts.items() if v > 1]
|
||||||
@ -37,10 +43,9 @@ def get_vcinema_viewings(token_id, token_secret, combine_repeat_viewings=True):
|
|||||||
viewing_indexes = [index for index, viewing in enumerate(viewings) if viewing['imdb_id'] == film]
|
viewing_indexes = [index for index, viewing in enumerate(viewings) if viewing['imdb_id'] == film]
|
||||||
|
|
||||||
first_watch = viewings[viewing_indexes[0]]
|
first_watch = viewings[viewing_indexes[0]]
|
||||||
first_watch['date_watched'] = [first_watch['date_watched']]
|
|
||||||
|
|
||||||
for index in viewing_indexes[1::]:
|
for index in viewing_indexes[1::]:
|
||||||
first_watch['date_watched'].append(viewings[index]['date_watched'])
|
first_watch['viewings'].append(viewings[index]['viewings'])
|
||||||
|
|
||||||
for index in reversed(viewing_indexes[1::]):
|
for index in reversed(viewing_indexes[1::]):
|
||||||
viewings.pop(index)
|
viewings.pop(index)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user