Skip to content

Commit 47794c3

Browse files
authored
hath: more robust folder name matching
1 parent 0344276 commit 47794c3

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

comiclib/scanner/21-hath.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +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-
match = re.search(r"\[(\d+)\]$", path.name)
14-
if match is not None:
13+
if (match := re.search(r"\[(\d+)\]$", path.name, re.ASCII)) is not None:
1514
metadata["source"] = 'https://exhentai.org/g/' + match[1] + '/'
16-
else:
15+
elif re.fullmatch(r"\d+", path.name, re.ASCII) is not None:
1716
metadata["source"] = 'https://exhentai.org/g/' + path.name + '/'
17+
else:
18+
raise Exception(f"Unknow hath folder name: {path.name}")
1819
information = (path / 'galleryinfo.txt').read_text().splitlines()
1920
_key, _, title = information[0].partition(':')
2021
assert _key == 'Title'
@@ -28,4 +29,4 @@ def scan(self, path: Path, id: str, metadata: dict, prev_scanners: list[str]) ->
2829
metadata["pagecount"] = len(list(path.iterdir())) - 1
2930
return True
3031
else:
31-
return False
32+
return False

0 commit comments

Comments
 (0)