use page of wikipedia page for table row
This commit is contained in:
parent
35d3637cd9
commit
e89eb33230
|
@ -1,7 +1,6 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import string
|
import wikipedia
|
||||||
|
|
||||||
from bookstack import Bookstack
|
|
||||||
from vcinema_utils import VCinemaUtils
|
from vcinema_utils import VCinemaUtils
|
||||||
|
|
||||||
# Page ID of https://wiki.jacknet.io/books/vcinema/page/references
|
# Page ID of https://wiki.jacknet.io/books/vcinema/page/references
|
||||||
|
@ -25,12 +24,32 @@ def build_page(films_by_reference_keyword):
|
||||||
|
|
||||||
table = "| Referenced | Films |\n| - | - |"
|
table = "| Referenced | Films |\n| - | - |"
|
||||||
|
|
||||||
for year in reference_keywords_sorted.keys():
|
for reference_keyword in reference_keywords_sorted.keys():
|
||||||
table += "\n"
|
table += "\n"
|
||||||
|
|
||||||
row_data = []
|
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.get_film_list(reference_keywords_sorted[year]))
|
referenced = reference_keyword[13:].replace("-", " ")
|
||||||
|
|
||||||
|
if referenced.startswith("a "):
|
||||||
|
referenced = referenced[2:]
|
||||||
|
else:
|
||||||
|
referenced = referenced
|
||||||
|
|
||||||
|
try:
|
||||||
|
searches = wikipedia.search(referenced, suggestion=False)
|
||||||
|
referenced_page = wikipedia.page(title=referenced, auto_suggest=False)
|
||||||
|
row_data.append("[{}]({}) ()".format(referenced_page.title, referenced_page.url, reference_keyword))
|
||||||
|
except wikipedia.DisambiguationError as e1:
|
||||||
|
row_data.append("[{}](https://en.wikipedia.org/wiki/{})) ()".format(e1.title, e1.title.replace(" ", "_"), reference_keyword))
|
||||||
|
except wikipedia.PageError as _:
|
||||||
|
try:
|
||||||
|
referenced_page = wikipedia.page(title=searches[0], auto_suggest=False)
|
||||||
|
row_data.append("[{}]({}) ()".format(referenced_page.title, referenced_page.url, reference_keyword))
|
||||||
|
except wikipedia.DisambiguationError as e2:
|
||||||
|
row_data.append(
|
||||||
|
"[{}](https://en.wikipedia.org/wiki/{})) ()".format(e2.title, e2.title.replace(" ", "_"),reference_keyword))
|
||||||
|
row_data.append(VCinemaUtils.get_film_list(reference_keywords_sorted[reference_keyword]))
|
||||||
|
|
||||||
table += " | ".join(row_data)
|
table += " | ".join(row_data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue