refactor and use helper function
This commit is contained in:
parent
19365a77d5
commit
b8128be130
|
@ -33,18 +33,18 @@ def get_films_by_reference(viewings):
|
||||||
page_title = referenced_page.title
|
page_title = referenced_page.title
|
||||||
page_url = referenced_page.url
|
page_url = referenced_page.url
|
||||||
|
|
||||||
except wikipedia.DisambiguationError as e1:
|
except wikipedia.DisambiguationError as e:
|
||||||
page_title = e1.title
|
page_title = e.title
|
||||||
page_url = "https://en.wikipedia.org/wiki/{}".format(e1.title.replace(" ", "_"))
|
page_url = VCinemaUtils.generate_wikipedia_url(page_title)
|
||||||
except wikipedia.PageError as _:
|
except wikipedia.PageError as _:
|
||||||
try:
|
try:
|
||||||
referenced_page = wikipedia.page(title=searches[0], auto_suggest=False)
|
referenced_page = wikipedia.page(title=searches[0], auto_suggest=False)
|
||||||
|
|
||||||
page_title = referenced_page.title
|
page_title = referenced_page.title
|
||||||
page_url = referenced_page.url
|
page_url = referenced_page.url
|
||||||
except wikipedia.DisambiguationError as e2:
|
except wikipedia.DisambiguationError as e:
|
||||||
page_title = e2.title
|
page_title = e.title
|
||||||
page_url = "https://en.wikipedia.org/wiki/{}".format(e2.title.replace(" ", "_"))
|
page_url = VCinemaUtils.generate_wikipedia_url(page_title)
|
||||||
|
|
||||||
if page_title in films_by_reference.keys():
|
if page_title in films_by_reference.keys():
|
||||||
films_by_reference[page_title]["films"].append(viewing)
|
films_by_reference[page_title]["films"].append(viewing)
|
||||||
|
|
Loading…
Reference in New Issue