From b9a4ee95303790a51b0871940c4a86aeb2584a1d Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 12 Mar 2022 12:16:13 +0000 Subject: [PATCH] allow viewings csv input in get_vcinema_viewings --- vcinema_utils/VCinemaUtils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vcinema_utils/VCinemaUtils.py b/vcinema_utils/VCinemaUtils.py index c002348..c617e85 100644 --- a/vcinema_utils/VCinemaUtils.py +++ b/vcinema_utils/VCinemaUtils.py @@ -19,10 +19,11 @@ def get_viewings_csv_attachment_id(token_id, token_secret): return next((x['id'] for x in attachments if x['uploaded_to'] == page_id and x['name'] == viewings_csv_file_name), None) -def get_vcinema_viewings(token_id, token_secret, combine_repeat_viewings=True): - attachment_id = get_viewings_csv_attachment_id(token_id, token_secret) +def get_vcinema_viewings(token_id, token_secret, viewings_csv=None, combine_repeat_viewings=True): + if viewings_csv is None: + attachment_id = get_viewings_csv_attachment_id(token_id, token_secret) + viewings_csv = Bookstack.get_attachment(JACKNET_WIKI_URL, token_id, token_secret, attachment_id) - viewings_csv = Bookstack.get_attachment(JACKNET_WIKI_URL, token_id, token_secret, attachment_id) viewings_csv = viewings_csv.decode("utf-8") viewings_csv_rows = viewings_csv.strip().split("\n")