Skip to content

Commit

Permalink
Merge pull request #10 from mizaki/web_links
Browse files Browse the repository at this point in the history
Change web_links to list and add min CT version
  • Loading branch information
mizaki authored Apr 23, 2024
2 parents f7e402b + 9f26466 commit e01b9cf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions gcd_talker/gcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
from comictalker.comictalker import ComicTalker, TalkerDataError, TalkerNetworkError
from pyrate_limiter import Limiter, RequestRate
from typing_extensions import TypedDict
from urllib3.exceptions import LocationParseError
from urllib3.util import parse_url

logger = logging.getLogger(f"comictalker.{__name__}")

Expand Down Expand Up @@ -95,6 +97,7 @@ class GCDCredit(TypedDict):
class GCDTalker(ComicTalker):
name: str = "Grand Comics Database"
id: str = "gcd"
comictagger_min_ver: str = "1.6.0a13"
website: str = "https://www.comics.org/"
logo_url: str = "https://files1.comics.org/static/img/gcd_logo.aaf0e64616e2.png"
attribution: str = (
Expand Down Expand Up @@ -247,13 +250,13 @@ def check_create_index(self) -> None:
logger.debug(f"DB error: {e}")
raise TalkerDataError(self.name, 0, str(e))

def check_db_filename_not_empty(self):
def check_db_filename_not_empty(self) -> None:
if not self.db_file:
raise TalkerDataError(self.name, 3, "Database path is empty, specify a path and filename!")
if not pathlib.Path(self.db_file).is_file():
raise TalkerDataError(self.name, 3, "Database path or filename is invalid!")

def check_db_fts5(self):
def check_db_fts5(self) -> None:
try:
with sqlite3.connect(self.db_file) as con:
con = sqlite3.connect(":memory:")
Expand Down Expand Up @@ -964,7 +967,12 @@ def _map_comic_issue_to_metadata(self, issue: GCDIssue, series: GCDSeries) -> Ge
else:
md.description += "\r\n\r\n".join(issue["synopses"])

md.web_link = urljoin(self.website, f"issue/{issue['id']}")
url = urljoin(self.website, f"issue/{issue['id']}")
if url:
try:
md.web_links = [parse_url(url)]
except LocationParseError:
...

md.volume = utils.xlate_int(issue.get("volume"))
if self.use_series_start_as_volume:
Expand Down

0 comments on commit e01b9cf

Please sign in to comment.