diff --git a/vcinema_utils/VCinemaUtils.py b/vcinema_utils/VCinemaUtils.py index 40681d3..1e80148 100644 --- a/vcinema_utils/VCinemaUtils.py +++ b/vcinema_utils/VCinemaUtils.py @@ -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 "
".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(" ", "_"))) diff --git a/wiki_pages/FilmsByReference.py b/wiki_pages/FilmsByReference.py index b3e5964..2c7b8aa 100644 --- a/wiki_pages/FilmsByReference.py +++ b/wiki_pages/FilmsByReference.py @@ -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)