From af66ffb2d9892857be4763166980830b99ac057a Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 18 Feb 2022 21:53:43 +0000 Subject: [PATCH] add get_viewings function --- .idea/vcs.xml | 7 +++++++ VCinemaUtils.py | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .idea/vcs.xml create mode 100644 VCinemaUtils.py diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..a27e640 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/VCinemaUtils.py b/VCinemaUtils.py new file mode 100644 index 0000000..f316800 --- /dev/null +++ b/VCinemaUtils.py @@ -0,0 +1,19 @@ +from bs4 import BeautifulSoup + +from wiki_utils.WikiUtils import * + + +def get_vcinema_viewings(token_id, token_secret): + # Page ID of /Vcinema/CSV + page_id = 11 + + wiki_base_url = "https://wiki.jacknet.io" + + html_page = get_page_export_html(page_id, wiki_base_url, token_id, token_secret) + + soup = BeautifulSoup(html_page, 'html.parser') + elements = soup.find("code").text.strip().split("\n") + headers = elements.pop(0).split(",") + viewings = [dict(zip(headers, row.split(","))) for row in elements] + + return viewings