From 74d7d56626a953ad1a4c982f8d522381e9487100 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 26 Mar 2022 00:15:50 +0000 Subject: [PATCH] refactor --- update_film_references.py | 2 +- update_viewings_csv.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/update_film_references.py b/update_film_references.py index b6f3389..c1e4ee2 100644 --- a/update_film_references.py +++ b/update_film_references.py @@ -4,7 +4,7 @@ import string from vcinema_utils import VCinemaUtils # Page ID of https://wiki.jacknet.io/books/vcinema/page/references -FILM_BY_REFERENCES_PAGE_ID = 63 +FILM_BY_REFERENCES_PAGE_ID = 62 def get_films_by_reference(viewings): diff --git a/update_viewings_csv.py b/update_viewings_csv.py index 411a65f..ad414c2 100644 --- a/update_viewings_csv.py +++ b/update_viewings_csv.py @@ -1,17 +1,16 @@ from bs4 import BeautifulSoup import hashlib - from bookstack import Bookstack from vcinema_utils import VCinemaUtils +# Page ID of https://wiki.jacknet.io/books/vcinema/page/csv +CSV_PAGE_ID = 11 + def update_viewings_csv(token_id, token_secret, check_existing=True): - # Page ID of https://wiki.jacknet.io/books/vcinema/page/csv - page_id = 11 - print("Retrieving viewings page") - html_page = Bookstack.get_page_html(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, page_id) + html_page = Bookstack.get_page_html(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, CSV_PAGE_ID) soup = BeautifulSoup(html_page, 'html.parser') csv_data = soup.find("code").text.strip().encode('utf-8') @@ -26,8 +25,8 @@ def update_viewings_csv(token_id, token_secret, check_existing=True): if not check_existing or page_hash != existing_attachment_hash: print("Updating file") # bookstack update file via api doesn't work - Bookstack.post_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, "vcinema.csv", csv_data, page_id) + Bookstack.post_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, "vcinema.csv", csv_data, CSV_PAGE_ID) Bookstack.delete_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, existing_attachment_id) print("File updated") else: - print("File already up-to-date") \ No newline at end of file + print("File already up-to-date")