Skip to content

Commit

Permalink
Merge pull request #8 from karuboniru/fix-hath
Browse files Browse the repository at this point in the history
fix Hath scanner crash on corner case  #7
  • Loading branch information
URenko authored Jan 16, 2024
2 parents 02c0ede + 47794c3 commit 56c1987
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions comiclib/scanner/21-hath.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ class Scanner:
def scan(self, path: Path, id: str, metadata: dict, prev_scanners: list[str]) -> bool:
if path.is_dir() and (path / 'galleryinfo.txt').exists():
logger.info(f' <- {path}')
metadata["source"] = 'https://exhentai.org/g/' + re.search(r"\[(\d+)\]$", path.name)[1] + '/'
if (match := re.search(r"\[(\d+)\]$", path.name, re.ASCII)) is not None:
metadata["source"] = 'https://exhentai.org/g/' + match[1] + '/'
elif re.fullmatch(r"\d+", path.name, re.ASCII) is not None:
metadata["source"] = 'https://exhentai.org/g/' + path.name + '/'
else:
raise Exception(f"Unknow hath folder name: {path.name}")
information = (path / 'galleryinfo.txt').read_text().splitlines()
_key, _, title = information[0].partition(':')
assert _key == 'Title'
Expand All @@ -24,4 +29,4 @@ def scan(self, path: Path, id: str, metadata: dict, prev_scanners: list[str]) ->
metadata["pagecount"] = len(list(path.iterdir())) - 1
return True
else:
return False
return False

0 comments on commit 56c1987

Please sign in to comment.