add helper functions

This commit is contained in:
Sarah 2022-12-04 14:11:27 +00:00
parent 35d3637cd9
commit d65dc51beb
2 changed files with 14 additions and 2 deletions

View File

@ -121,10 +121,22 @@ def get_film_list(films):
film_links = []
for film in films:
film_link = "[{}](https://www.imdb.com/title/tt{}/)".format(film['title'], film['imdb_id'])
film_link = generate_imdb_film_link(film)
film_links.append(film_link)
if len(film_links) > 0:
return "<br>".join(film_links)
else:
return ""
def generate_markdown_link(text, url):
return "[{}]({})".format(text, url)
def generate_imdb_film_link(film):
return generate_markdown_link(film['title'], "https://www.imdb.com/title/tt{}/".format(film['imdb_id']))
def generate_wikipedia_page_link(page_title):
return generate_markdown_link(page_title, "https://en.wikipedia.org/wiki/{}".format(page_title.replace(" ", "_")))

View File

@ -29,7 +29,7 @@ def build_page(films_by_reference_keyword):
table += "\n"
row_data = []
row_data.append("[{}](https://en.wikipedia.org/wiki/{})".format(str(string.capwords(year[13:].replace("-", " "))), str(string.capwords(year[13:].replace("-", " ")).replace(" ", "_"))))
row_data.append(VCinemaUtils.generate_wikipedia_page_link(string.capwords(year[13:].replace("-", " "))))
row_data.append(VCinemaUtils.get_film_list(reference_keywords_sorted[year]))
table += " | ".join(row_data)