This commit is contained in:
Sarah 2022-03-26 00:15:50 +00:00
parent 06fa6729f7
commit 74d7d56626
2 changed files with 7 additions and 8 deletions

View File

@ -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):

View File

@ -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")
print("File already up-to-date")