vcinema/update_film_references.py

28 lines
1.0 KiB
Python

from collections import OrderedDict
import string
from vcinema_utils import VCinemaUtils
# Page ID of https://wiki.jacknet.io/books/vcinema/page/references
FILM_BY_REFERENCES_PAGE_ID = 62
def get_films_by_reference(viewings):
viewings_filtered_by_keyword = VCinemaUtils.filter_viewings(viewings, "keywords")
viewings_filtered_by_reference_keyword = {k: v for k, v in viewings_filtered_by_keyword.items() if k.startswith("reference-to")}
return viewings_filtered_by_reference_keyword
def build_page(films_by_reference_keyword):
reference_keywords_sorted = OrderedDict(sorted(films_by_reference_keyword.items(), key=lambda t: t[0]))
films_by_reference_table = "| Referenced | Films |\n| - | - |"
for year in reference_keywords_sorted.keys():
films_by_reference_table += "\n"
films_by_reference_table += str(string.capwords(year[13:].replace("-", " "))) + " | "
films_by_reference_table += VCinemaUtils.get_film_list(reference_keywords_sorted[year])
return films_by_reference_table