2022-03-25 22:19:40 +00:00
|
|
|
from collections import OrderedDict
|
|
|
|
import string
|
|
|
|
|
|
|
|
from vcinema_utils import VCinemaUtils
|
|
|
|
|
|
|
|
# Page ID of https://wiki.jacknet.io/books/vcinema/page/references
|
2022-03-26 00:15:50 +00:00
|
|
|
FILM_BY_REFERENCES_PAGE_ID = 62
|
2022-03-25 22:19:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2022-04-03 22:27:49 +01:00
|
|
|
def build_page(films_by_reference_keyword):
|
|
|
|
reference_keywords_sorted = OrderedDict(sorted(films_by_reference_keyword.items(), key=lambda t: t[0]))
|
2022-03-25 22:19:40 +00:00
|
|
|
|
|
|
|
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
|