fix for reference and fix imports
This commit is contained in:
parent
15f04eabd4
commit
08c22b1277
|
@ -1,4 +1,4 @@
|
||||||
import vcinema_utils
|
from vcinema_utils.VCinemaUtils import *
|
||||||
from vcinema_utils.Viewing import Viewing
|
from vcinema_utils.Viewing import Viewing
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class VCinemaFilm:
|
||||||
return "https://www.imdb.com/title/tt{}/".format(self._imdb_id)
|
return "https://www.imdb.com/title/tt{}/".format(self._imdb_id)
|
||||||
|
|
||||||
def get_imdb_link(self):
|
def get_imdb_link(self):
|
||||||
return vcinema_utils.VCinemaUtils.generate_markdown_link(self._title, self.get_imdb_url())
|
return generate_markdown_link(self._title, self.get_imdb_url())
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
return self._title
|
return self._title
|
||||||
|
|
|
@ -2,23 +2,23 @@ from collections import OrderedDict
|
||||||
import wikipedia
|
import wikipedia
|
||||||
|
|
||||||
from bookstack import Bookstack
|
from bookstack import Bookstack
|
||||||
from vcinema_utils import VCinemaUtils
|
from vcinema_utils import VCinemaUtils, VCinemaFilm
|
||||||
|
|
||||||
# Page ID of https://wiki.jacknet.io/books/vcinema/page/references
|
# Page ID of https://wiki.jacknet.io/books/vcinema/page/references
|
||||||
PAGE_ID = 62
|
PAGE_ID = 62
|
||||||
|
|
||||||
|
|
||||||
def get_films_by_reference(viewings):
|
def get_films_by_reference(films: [VCinemaFilm]):
|
||||||
films_by_reference = {}
|
films_by_reference = {}
|
||||||
|
|
||||||
for viewing in viewings:
|
for film in films:
|
||||||
if "keywords" in viewing.keys():
|
if (film_keywords := film.get_imdb_data("keywords")) is not None:
|
||||||
for keyword in viewing["keywords"]:
|
for keyword in film_keywords:
|
||||||
if keyword.startswith("reference-to-"):
|
if keyword.startswith("reference-to-"):
|
||||||
|
|
||||||
for reference in films_by_reference:
|
for reference in films_by_reference:
|
||||||
if keyword in films_by_reference[reference]["keywords"]:
|
if keyword in films_by_reference[reference]["keywords"]:
|
||||||
films_by_reference[reference]["films"].append(viewing)
|
films_by_reference[reference]["films"].append(film)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
keyword = keyword[13:]
|
keyword = keyword[13:]
|
||||||
|
@ -31,13 +31,13 @@ def get_films_by_reference(viewings):
|
||||||
|
|
||||||
referenced = keyword.replace("-", " ")
|
referenced = keyword.replace("-", " ")
|
||||||
|
|
||||||
|
searches = wikipedia.search(referenced, suggestion=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
searches = wikipedia.search(referenced, suggestion=False)
|
|
||||||
referenced_page = wikipedia.page(title=referenced, auto_suggest=False)
|
referenced_page = wikipedia.page(title=referenced, 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:]
|
||||||
|
@ -60,13 +60,13 @@ def get_films_by_reference(viewings):
|
||||||
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)
|
||||||
|
|
||||||
if viewing not in films_by_reference[page_title]["films"]:
|
if film not in films_by_reference[page_title]["films"]:
|
||||||
films_by_reference[page_title]["films"].append(viewing)
|
films_by_reference[page_title]["films"].append(film)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
films_by_reference[page_title] = {"url": page_url,
|
films_by_reference[page_title] = {"url": page_url,
|
||||||
"keywords": [keyword],
|
"keywords": [keyword],
|
||||||
"films": [viewing]}
|
"films": [film]}
|
||||||
|
|
||||||
return films_by_reference
|
return films_by_reference
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue