diff --git a/comiclib/scanner/21-hath.py b/comiclib/scanner/21-hath.py index 1cb57e3..1ca988a 100644 --- a/comiclib/scanner/21-hath.py +++ b/comiclib/scanner/21-hath.py @@ -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' @@ -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 \ No newline at end of file + return False