vcinema/update_films_by_year.py

30 lines
773 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-04-03 22:27:49 +01:00
def build_page(films_by_year):
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-04-03 22:27:49 +01:00
page = "| Year | Films |\n| - | - |"
2022-02-27 14:34:23 +00:00
for year in films_by_year_sorted.keys():
2022-04-03 22:27:49 +01:00
page += "\n"
2022-04-08 22:01:58 +01:00
row_data = []
row_data.append(str(year))
row_data.append(VCinemaUtils.get_film_list(films_by_year_sorted[year]))
page += " | ".join(row_data)
2022-02-20 21:26:38 +00:00
2022-04-03 22:27:49 +01:00
return page