34 lines
975 B
Python
34 lines
975 B
Python
from collections import OrderedDict
|
|
|
|
from bookstack import Bookstack
|
|
from markdown_utils import MarkdownUtils
|
|
from vcinema_utils import VCinemaUtils
|
|
|
|
# Page ID of https://wiki.jacknet.io/books/vcinema/page/films-by-release-year
|
|
PAGE_ID = 24
|
|
|
|
|
|
def get_films_by_year(viewings):
|
|
viewings_filtered_by_year = VCinemaUtils.filter_viewings(viewings, "year")
|
|
|
|
return viewings_filtered_by_year
|
|
|
|
|
|
def update_page(token_id, token_secret, films_by_year):
|
|
page = build_page(films_by_year)
|
|
Bookstack.update_page(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, PAGE_ID, markdown=page)
|
|
|
|
|
|
def build_page(films_by_year):
|
|
films_by_year = OrderedDict(sorted(films_by_year.items(), key=lambda t: t[0], reverse=True))
|
|
|
|
table = MarkdownUtils.MarkdownTable(["Year", "Films"])
|
|
|
|
for year in films_by_year.keys():
|
|
films = VCinemaUtils.get_film_list(films_by_year[year])
|
|
|
|
row_data = [year, films]
|
|
table.add_row(row_data)
|
|
|
|
return str(table)
|