refactor and use helper function

This commit is contained in:
Sarah 2022-12-04 14:18:30 +00:00
parent 19365a77d5
commit b8128be130
1 changed files with 6 additions and 6 deletions

View File

@ -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)