Merge pull request 'fix bug where script throws exception if no page exists for a reference keyword' (#14) from bugfix/exception-thrown-if-no-page-exists-for-reference into master
Reviewed-on: #14
This commit is contained in:
commit
467ee78f59
|
@ -43,15 +43,19 @@ def get_films_by_reference(viewings):
|
||||||
page_title = page_title[0].upper() + page_title[1:]
|
page_title = page_title[0].upper() + page_title[1:]
|
||||||
page_url = VCinemaUtils.generate_wikipedia_url(page_title)
|
page_url = VCinemaUtils.generate_wikipedia_url(page_title)
|
||||||
except wikipedia.PageError as _:
|
except wikipedia.PageError as _:
|
||||||
try:
|
if len(searches) > 0:
|
||||||
referenced_page = wikipedia.page(title=searches[0], auto_suggest=False)
|
try:
|
||||||
|
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 e:
|
except wikipedia.DisambiguationError as e:
|
||||||
page_title = e.title
|
page_title = e.title
|
||||||
page_title = page_title[0].upper() + page_title[1:]
|
page_title = page_title[0].upper() + page_title[1:]
|
||||||
page_url = VCinemaUtils.generate_wikipedia_url(page_title)
|
page_url = VCinemaUtils.generate_wikipedia_url(page_title)
|
||||||
|
else:
|
||||||
|
page_title = referenced.title()
|
||||||
|
page_url = None
|
||||||
|
|
||||||
if page_title in films_by_reference.keys():
|
if page_title in films_by_reference.keys():
|
||||||
films_by_reference[page_title]["keywords"].append(keyword)
|
films_by_reference[page_title]["keywords"].append(keyword)
|
||||||
|
@ -85,7 +89,10 @@ def build_page(films_by_reference):
|
||||||
reference_url = referenced["url"]
|
reference_url = referenced["url"]
|
||||||
referenced_films = referenced["films"]
|
referenced_films = referenced["films"]
|
||||||
|
|
||||||
row_data.append(VCinemaUtils.generate_markdown_link(reference, reference_url))
|
if reference_url is None:
|
||||||
|
row_data.append(reference)
|
||||||
|
else:
|
||||||
|
row_data.append(VCinemaUtils.generate_markdown_link(reference, reference_url))
|
||||||
row_data.append(VCinemaUtils.get_film_list(referenced_films))
|
row_data.append(VCinemaUtils.get_film_list(referenced_films))
|
||||||
|
|
||||||
table += " | ".join(row_data)
|
table += " | ".join(row_data)
|
||||||
|
|
Loading…
Reference in New Issue