refactor
This commit is contained in:
parent
06fa6729f7
commit
74d7d56626
@ -4,7 +4,7 @@ import string
|
|||||||
from vcinema_utils import VCinemaUtils
|
from vcinema_utils import VCinemaUtils
|
||||||
|
|
||||||
# Page ID of https://wiki.jacknet.io/books/vcinema/page/references
|
# 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):
|
def get_films_by_reference(viewings):
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
from bookstack import Bookstack
|
from bookstack import Bookstack
|
||||||
from vcinema_utils import VCinemaUtils
|
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):
|
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")
|
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')
|
soup = BeautifulSoup(html_page, 'html.parser')
|
||||||
csv_data = soup.find("code").text.strip().encode('utf-8')
|
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:
|
if not check_existing or page_hash != existing_attachment_hash:
|
||||||
print("Updating file")
|
print("Updating file")
|
||||||
# bookstack update file via api doesn't work
|
# 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)
|
Bookstack.delete_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, existing_attachment_id)
|
||||||
print("File updated")
|
print("File updated")
|
||||||
else:
|
else:
|
||||||
print("File already up-to-date")
|
print("File already up-to-date")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user