vcinema/update_film_references.py

30 lines
1.1 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(reference_keywords):
reference_keywords_sorted = OrderedDict(sorted(reference_keywords.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("-", " "))) + " | "
film_links = ["[{}](https://www.imdb.com/title/tt{}/)".format(film['title'], film['imdb_id']) for film in reference_keywords_sorted[year]]
films_by_reference_table += "<br>".join(film_links)
return films_by_reference_table