Compare commits

...

4 Commits

Author SHA1 Message Date
Sarah
b32d5aa6c6 remove newline 2022-03-09 20:48:05 +00:00
Sarah
0a3798b13e ignore warning and fix output 2022-03-09 20:47:35 +00:00
Sarah
8fcfacbdc5 re-add fields 2022-03-09 20:47:19 +00:00
Sarah
23f4608cc8 fix output 2022-03-09 20:22:14 +00:00
5 changed files with 548 additions and 5 deletions

38
test.py Normal file
View File

@ -0,0 +1,38 @@
import os
import os.path
import ssl
import stat
import subprocess
import sys
STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
| stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
| stat.S_IROTH | stat.S_IXOTH )
def main():
openssl_dir, openssl_cafile = os.path.split(
ssl.get_default_verify_paths().openssl_cafile)
print(" -- pip install --upgrade certifi")
subprocess.check_call([sys.executable,
"-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])
import certifi
# change working directory to the default SSL directory
os.chdir(openssl_dir)
relpath_to_certifi_cafile = os.path.relpath(certifi.where())
print(" -- removing any existing file or link")
try:
os.remove(openssl_cafile)
except FileNotFoundError:
pass
print(" -- creating symlink to certifi certificate bundle")
os.symlink(relpath_to_certifi_cafile, openssl_cafile)
print(" -- setting permissions")
os.chmod(openssl_cafile, STAT_0o775)
print(" -- update complete")
if __name__ == '__main__':
main()

View File

@ -5,6 +5,8 @@ import os
from progress.bar import Bar from progress.bar import Bar
from wand.image import Image from wand.image import Image
import worldmap import worldmap
import warnings
warnings.filterwarnings("ignore")
from bookstack import Bookstack from bookstack import Bookstack
@ -123,8 +125,8 @@ def update_films_by_country_page(token_id, token_secret):
with Bar('Generating table', max=country_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar: with Bar('Generating table', max=country_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
film_by_country_table = build_table(viewings_by_country, bar) film_by_country_table = build_table(viewings_by_country, bar)
print("Drawing map")
country_counter = Counter(viewings_by_country) country_counter = Counter(viewings_by_country)
png_data = draw_map(country_counter) png_data = draw_map(country_counter)
update_page(png_data, film_by_country_table, VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret) update_page(png_data, film_by_country_table, VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret)

View File

@ -31,7 +31,7 @@ def update_films_by_year_page(token_id, token_secret):
viewing_count = len(viewings) viewing_count = len(viewings)
with Bar('Retrieving movie data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar: with Bar('Retrieving movie data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
VCinemaUtils.add_imdb_data_to_viewings(viewings, bar) VCinemaUtils.add_imdb_data_to_viewings(viewings, ['year'], bar)
with Bar('Processing viewing data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar: with Bar('Processing viewing data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
viewings_by_year = VCinemaUtils.filter_viewings(viewings, 'year', bar) viewings_by_year = VCinemaUtils.filter_viewings(viewings, 'year', bar)

View File

@ -11,11 +11,13 @@ def update_viewings_csv_file_from_page(token_id, token_secret):
# Page ID of https://wiki.jacknet.io/books/vcinema/page/csv # Page ID of https://wiki.jacknet.io/books/vcinema/page/csv
page_id = 11 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, 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')
print("Retrieving existing file")
existing_attachment_id = VCinemaUtils.get_viewings_csv_attachment_id(token_id, token_secret) existing_attachment_id = VCinemaUtils.get_viewings_csv_attachment_id(token_id, token_secret)
attachment = Bookstack.get_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, existing_attachment_id) attachment = Bookstack.get_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, existing_attachment_id)
@ -25,13 +27,13 @@ def update_viewings_csv_file_from_page(token_id, token_secret):
page_hash = hashlib.md5(csv_data).hexdigest() page_hash = hashlib.md5(csv_data).hexdigest()
if page_hash != existing_attachment_hash: if 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, 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("done") print("Done")
else: else:
print("file already up to date") print("File already up to date")
if __name__ == '__main__': if __name__ == '__main__':

501
vcinema_map.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 1.3 MiB