Skip to content

Commit 56c1987

Browse files
authored
Merge pull request #8 from karuboniru/fix-hath
fix Hath scanner crash on corner case #7
2 parents 02c0ede + 47794c3 commit 56c1987

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

comiclib/scanner/21-hath.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ class Scanner:
1010
def scan(self, path: Path, id: str, metadata: dict, prev_scanners: list[str]) -> bool:
1111
if path.is_dir() and (path / 'galleryinfo.txt').exists():
1212
logger.info(f' <- {path}')
13-
metadata["source"] = 'https://exhentai.org/g/' + re.search(r"\[(\d+)\]$", path.name)[1] + '/'
13+
if (match := re.search(r"\[(\d+)\]$", path.name, re.ASCII)) is not None:
14+
metadata["source"] = 'https://exhentai.org/g/' + match[1] + '/'
15+
elif re.fullmatch(r"\d+", path.name, re.ASCII) is not None:
16+
metadata["source"] = 'https://exhentai.org/g/' + path.name + '/'
17+
else:
18+
raise Exception(f"Unknow hath folder name: {path.name}")
1419
information = (path / 'galleryinfo.txt').read_text().splitlines()
1520
_key, _, title = information[0].partition(':')
1621
assert _key == 'Title'
@@ -24,4 +29,4 @@ def scan(self, path: Path, id: str, metadata: dict, prev_scanners: list[str]) ->
2429
metadata["pagecount"] = len(list(path.iterdir())) - 1
2530
return True
2631
else:
27-
return False
32+
return False

0 commit comments

Comments
 (0)