vcinema/update_films_by_year.py

34 lines
992 B
Python
Raw Normal View History

2022-02-20 21:26:38 +00:00
from collections import OrderedDict
from vcinema_utils import VCinemaUtils
2022-03-25 17:55:52 +00:00
# Page ID of https://wiki.jacknet.io/books/vcinema/page/films-by-release-year
FILMS_BY_YEAR_PAGE_ID = 24
2022-02-20 21:26:38 +00:00
2022-03-25 17:55:52 +00:00
2022-03-25 22:17:11 +00:00
def get_films_by_year(viewings):
viewings_filtered_by_year = VCinemaUtils.filter_viewings(viewings, "year")
return viewings_filtered_by_year
2022-03-25 17:55:52 +00:00
def build_page(films_by_year, progressbar=None):
2022-02-27 13:54:18 +00:00
films_by_year_sorted = OrderedDict(sorted(films_by_year.items(), key=lambda t: t[0], reverse=True))
2022-02-20 21:26:38 +00:00
2022-03-25 17:55:52 +00:00
page_table = "| Year | Films |\n| - | - |"
2022-02-27 14:34:23 +00:00
for year in films_by_year_sorted.keys():
2022-03-25 17:55:52 +00:00
page_table += "\n"
page_table += str(year) + " | "
2022-03-25 22:19:05 +00:00
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)
2022-02-27 14:34:23 +00:00
if progressbar is not None:
progressbar.next()
2022-02-20 21:26:38 +00:00
if progressbar is not None:
progressbar.finish()
2022-02-20 21:26:38 +00:00
return page_table