vcinema/update_films_by_year.py

34 lines
992 B
Python

from collections import OrderedDict
from vcinema_utils import VCinemaUtils
# Page ID of https://wiki.jacknet.io/books/vcinema/page/films-by-release-year
FILMS_BY_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 build_page(films_by_year, progressbar=None):
films_by_year_sorted = OrderedDict(sorted(films_by_year.items(), key=lambda t: t[0], reverse=True))
page_table = "| Year | Films |\n| - | - |"
for year in films_by_year_sorted.keys():
page_table += "\n"
page_table += str(year) + " | "
film_links = ["[{}](https://www.imdb.com/title/tt{}/)".format(film['title'], film['imdb_id']) for film in films_by_year_sorted[year]]
page_table += "<br>".join(film_links)
if progressbar is not None:
progressbar.next()
if progressbar is not None:
progressbar.finish()
return page_table