Skip to content

Commit ab8b057

Browse files
committed
support xeHentai
1 parent 03c10e4 commit ab8b057

6 files changed

Lines changed: 42 additions & 5 deletions

File tree

comiclib/scanner/20-ccloli.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ def scan(self, path: Path, id: str, metadata: dict, prev_scanners: list[str]) ->
2828
else:
2929
return False
3030
logger.info(f' <- {path}')
31-
if "hentai.org" not in info[2]: return False
32-
metadata["title"] = info[0]
33-
metadata["subtitle"] = info[1]
3431
metadata["source"] = info[2]
3532
m = re.match(r"https?://e[x-]hentai\.org/g/(\d+)/(\w+)", metadata["source"])
3633
if m is None:
37-
logger.error(metadata["source"])
38-
raise NotImplementedError('Unknow source format.')
34+
return False
35+
metadata["title"] = info[0]
36+
metadata["subtitle"] = info[1]
3937
metadata["id"] = f"EH{m[1]:>018}{m[2]}{id[-10:]}"
4038
line_tags = False
4139
for line in info:

comiclib/scanner/23-xeHentai.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pathlib import Path
2+
from zipfile import ZipFile
3+
import re
4+
5+
import logging
6+
logger = logging.getLogger(__name__)
7+
8+
class Scanner:
9+
'''For https://github.com/fffonion/xeHentai'''
10+
11+
def scan(self, path: Path, id: str, metadata: dict, prev_scanners: list[str]) -> bool:
12+
if not '10-zip' in prev_scanners or '20-ccloli' in prev_scanners:
13+
return False
14+
with ZipFile(path) as z:
15+
try:
16+
comment = z.comment.decode("utf-8")
17+
except UnicodeDecodeError:
18+
return False
19+
if (m := re.fullmatch('xeHentai Archiver v\\S+\nTitle:(.+)\nOriginal URL:(\\S+)', comment)) is not None:
20+
metadata["title"] = m[1]
21+
metadata["source"] = m[2]
22+
source = re.match(r"https?://e[x-]hentai\.org/g/(\d+)/(\w+)", metadata["source"])
23+
if source is None:
24+
logger.error(metadata["source"])
25+
raise NotImplementedError('Unknow source format.')
26+
metadata["id"] = f"EH{source[1]:>018}{source[2]}{id[-10:]}"
27+
return True
28+
else:
29+
return False

docs/en/docs/scanner.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Parse comic folders downloaded via [Hentai@Home](https://ehwiki.org/wiki/Hentai@
3636

3737
Parse comic folders downloaded via [EhViewer](https://github.com/seven332/EhViewer).
3838

39+
### 23-xeHentai.py
40+
41+
Parse comic files downloaded via [xeHentai](https://github.com/fffonion/xeHentai).
42+
3943
### 30-importEHdb.py
4044

4145
Import the corresponding metadata from [ehentai metadata database](https://sukebei.nyaa.si/user/gipaf23445).

docs/en/docs/supported-formats.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
| zip | general | 10-zip.py |
66
| rar, 7z [^1] | general | 11-archive.py |
77
| zip | [ccloli/E-Hentai-Downloader](https://github.com/ccloli/E-Hentai-Downloader) | 20-ccloli.py |
8+
| zip | [xeHentai](https://github.com/fffonion/xeHentai) | 23-xeHentai.py |
89
| folder | [Hentai@Home](https://ehwiki.org/wiki/Hentai@Home#H.40H_Downloader) | 21-hath.py |
910
| folder | [EhViewer](https://github.com/seven332/EhViewer) | 22-ehviewer.py |
1011

docs/zh/docs/scanner.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ ComicLib 的主体仅负责遍历漫画库,漫画文件的判断、解析等
3535

3636
解析通过 [EhViewer](https://github.com/seven332/EhViewer) 下载的漫画文件夹。
3737

38+
### 23-xeHentai.py
39+
40+
解析通过 [xeHentai](https://github.com/fffonion/xeHentai) 下载的漫画文件。
41+
3842
### 30-importEHdb.py
3943

4044
[ehentai 元数据库](https://sukebei.nyaa.si/user/gipaf23445)导入相应的元数据。

docs/zh/docs/supported-formats.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
| zip | 一般 | 10-zip.py |
66
| rar, 7z [^1] | 一般 | 11-archive.py |
77
| zip | [ccloli/E-Hentai-Downloader](https://github.com/ccloli/E-Hentai-Downloader) | 20-ccloli.py |
8+
| zip | [xeHentai](https://github.com/fffonion/xeHentai) | 23-xeHentai.py |
89
| 文件夹 | [Hentai@Home](https://ehwiki.org/wiki/Hentai@Home#H.40H_Downloader) | 21-hath.py |
910
| 文件夹 | [EhViewer](https://github.com/seven332/EhViewer) | 22-ehviewer.py |
1011

0 commit comments

Comments
 (0)