2022-03-08 22:51:21 +00:00
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
|
|
|
from bookstack import Bookstack
|
|
|
|
from vcinema_utils import VCinemaUtils
|
|
|
|
|
2022-03-26 00:15:50 +00:00
|
|
|
# Page ID of https://wiki.jacknet.io/books/vcinema/page/csv
|
2022-04-15 17:29:19 +01:00
|
|
|
PAGE_ID = 11
|
2022-03-08 22:51:21 +00:00
|
|
|
|
|
|
|
|
2022-09-05 23:21:03 +01:00
|
|
|
def update_viewings_csv(token_id, token_secret):
|
2022-03-09 20:22:14 +00:00
|
|
|
print("Retrieving viewings page")
|
2022-04-18 23:04:11 +01:00
|
|
|
html_page = Bookstack.get_page_html(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, PAGE_ID)
|
2022-03-08 22:51:21 +00:00
|
|
|
|
|
|
|
soup = BeautifulSoup(html_page, 'html.parser')
|
2022-03-08 22:53:24 +00:00
|
|
|
csv_data = soup.find("code").text.strip().encode('utf-8')
|
2022-03-08 22:51:21 +00:00
|
|
|
|
2022-09-05 23:21:03 +01:00
|
|
|
existing_attachment_id = VCinemaUtils.get_viewings_csv_attachment_id(token_id, token_secret)
|
|
|
|
print("Updating file")
|
|
|
|
Bookstack.update_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, existing_attachment_id, "vcinema.csv", csv_data, PAGE_ID)
|
|
|
|
print("File updated")
|