Skip to content

Commit bc9990c

Browse files
committed
support comics downloaded via EhViewer
1 parent 1f0cb0e commit bc9990c

5 files changed

Lines changed: 29 additions & 2 deletions

File tree

comiclib/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def extract_archive(id: str, force: bool, db: Session = Depends(get_db)):
257257
return JSONResponse({"operation": "", "error": "This ID doesn't exist on the server.", "success": 0}, status.HTTP_400_BAD_REQUEST)
258258
path = Path(settings.content) / a.path
259259
if path.is_dir():
260-
pages = [f"./api/archives/{id}/page?path="+quote(p.name, safe='') for p in sorted(path.iterdir()) if p.suffix != '.txt']
260+
pages = [f"./api/archives/{id}/page?path="+quote(p.name, safe='') for p in sorted(path.iterdir()) if p.suffix != '.txt' and not p.name.startswith('.')]
261261
elif path.suffix == '.zip':
262262
with ZipFile(path) as z:
263263
pages = [f"./api/archives/{id}/page?path="+quote(z_info.filename, safe='') for z_info in filter(

comiclib/scanner/22-ehviewer.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from pathlib import Path
2+
import re
3+
4+
import logging
5+
logger = logging.getLogger(__name__)
6+
7+
class Scanner:
8+
'''For archives downloaded via Ehviewer'''
9+
10+
def scan(self, path: Path, id: str, metadata: dict, prev_scanners: list[str]) -> bool:
11+
if path.is_dir() and not (m := re.match(r'(\d+)-(.+)', path.name)) is None:
12+
logger.info(f' <- {path}')
13+
metadata["source"] = 'https://exhentai.org/g/' + m[1] + '/'
14+
metadata["title"] = m[2]
15+
metadata["pagecount"] = len([p for p in path.iterdir() if not p.name.startswith('.')])
16+
return metadata["pagecount"] > 0
17+
else:
18+
return False

comiclib/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def extract_thumbnail(path: Union[str, Path], id: str, page: int, cache=False) -
4040
return saveto.relative_to(settings.thumb)
4141
saveto.parent.mkdir(parents=True, exist_ok=True)
4242
if path.is_dir():
43-
convert_image(sorted(filter(lambda p:p.suffix != '.txt', path.iterdir()))[page-1], saveto, thumbnail=True)
43+
convert_image(sorted(filter(lambda p:p.suffix != '.txt' and not p.name.startswith('.'), path.iterdir()))[page-1], saveto, thumbnail=True)
44+
return saveto.relative_to(settings.thumb)
4445
elif path.suffix == '.zip':
4546
with ZipFile(path) as z:
4647
with z.open(list(filter(lambda z_info: not z_info.is_dir(), z.infolist()))[page-1].filename) as f:

docs/en/docs/scanner.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Parse comic files downloaded via [ccloli/E-Hentai-Downloader](https://github.com
2727

2828
Parse comic folders downloaded via [Hentai@Home](https://ehwiki.org/wiki/Hentai@Home#H.40H_Downloader).
2929

30+
### 22-ehviewer.py
31+
32+
Parse comic folders downloaded via [EhViewer](https://github.com/seven332/EhViewer).
33+
3034
### 30-importEHdb.py
3135

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

docs/zh/docs/scanner.md

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

2727
解析通过 [Hentai@Home](https://ehwiki.org/wiki/Hentai@Home#H.40H_Downloader) 下载的漫画文件夹。
2828

29+
### 22-ehviewer.py
30+
31+
解析通过 [EhViewer](https://github.com/seven332/EhViewer) 下载的漫画文件夹。
32+
2933
### 30-importEHdb.py
3034

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

0 commit comments

Comments
 (0)