From b8128be130934cb8f97a75d8a09445305eaa418a Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 4 Dec 2022 14:18:30 +0000 Subject: [PATCH] refactor and use helper function --- wiki_pages/FilmsByReference.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wiki_pages/FilmsByReference.py b/wiki_pages/FilmsByReference.py index 2f714a8..1a00556 100644 --- a/wiki_pages/FilmsByReference.py +++ b/wiki_pages/FilmsByReference.py @@ -33,18 +33,18 @@ def get_films_by_reference(viewings): page_title = referenced_page.title page_url = referenced_page.url - except wikipedia.DisambiguationError as e1: - page_title = e1.title - page_url = "https://en.wikipedia.org/wiki/{}".format(e1.title.replace(" ", "_")) + except wikipedia.DisambiguationError as e: + page_title = e.title + page_url = VCinemaUtils.generate_wikipedia_url(page_title) except wikipedia.PageError as _: try: referenced_page = wikipedia.page(title=searches[0], auto_suggest=False) page_title = referenced_page.title page_url = referenced_page.url - except wikipedia.DisambiguationError as e2: - page_title = e2.title - page_url = "https://en.wikipedia.org/wiki/{}".format(e2.title.replace(" ", "_")) + except wikipedia.DisambiguationError as e: + page_title = e.title + page_url = VCinemaUtils.generate_wikipedia_url(page_title) if page_title in films_by_reference.keys(): films_by_reference[page_title]["films"].append(viewing)