Skip to content

Commit e6e09df

Browse files
committed
adapt Ichaival
1 parent 0b8977e commit e6e09df

5 files changed

Lines changed: 20 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ English | [中文](https://github.com/comiclib/comiclib/blob/master/README.zh.md
66
💬 Join Discussion: [![Discord](https://img.shields.io/discord/1100655762411372604?logo=discord&style=flat-square)](https://discord.gg/UmjCbgGUFW)
77

88
# ✨ Features
9-
- 📁 Support multiple archive formats
9+
- 📁 Support [multiple archive formats](https://comiclib.github.io/comiclib/en/supported-formats/)
1010
- 🏷️ Support tag and category metadata import and management
1111
- 🔌 Support [plugins](https://comiclib.github.io/comiclib/en/scanner/)
1212
- 🖼️ Support JPEG XL

README.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
💬 加入讨论: [![Discord](https://img.shields.io/discord/1100655762411372604?logo=discord&style=flat-square)](https://discord.gg/UmjCbgGUFW)
77

88
# ✨ 特点
9-
- 📁 支持多种存档格式
9+
- 📁 支持[多种存档格式](https://comiclib.github.io/comiclib/zh/supported-formats/)
1010
- 🏷️ 支持tag和分类元数据导入和管理
1111
- 🔌 支持[插件](https://comiclib.github.io/comiclib/zh/scanner/)
1212
- 🖼️ 支持JPEG XL

comiclib/main.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ def do_search(db: Session, category: str, filters: str, order: Union[OrderingDir
9090
else:
9191
filters += ', ' + search
9292
for f in filter(None, map(str.strip, filters.split(','))):
93+
pre = suff = '%'
94+
if f[-1] == '$':
95+
f = f[:-1]
96+
suff = ''
9397
if f[0] == '"' and f[-1] == '"':
9498
f = f.strip('"')
95-
elif f[-1] == '$':
96-
f = f'%{f[:-1]}'
97-
else:
98-
f = f'%{f}%'
99+
pre = suff = ''
100+
f = pre + f + suff
99101
f.replace('*', '%').replace('?', '_')
100102
stmt = stmt.where(or_(Archive.title.like(f), Archive.subtitle.like(f), Archive.id.in_(select(Archive.id).outerjoin(Archive.tags).where(Tag.tag.like(f)))))
101103
if order is None:
@@ -122,7 +124,7 @@ def do_search(db: Session, category: str, filters: str, order: Union[OrderingDir
122124

123125

124126
@app.get("/api/search")
125-
def search_archive(category: str, filter: str, start: int, order: OrderingDirection, sortby: str = "title", db: Session = Depends(get_db)):
127+
def search_archive(filter: str, start: int, order: OrderingDirection, category: str = '', sortby: str = "title", db: Session = Depends(get_db)):
126128
data, recordsFiltered, recordsTotal = do_search(db, category=category, filters=filter,
127129
start=start, order=order, sortby=sortby, query_total=True)
128130
return {"data": data, "draw": 0, "recordsFiltered": recordsFiltered, "recordsTotal": recordsTotal}
@@ -254,7 +256,7 @@ def download_archive(id: str, db: Session = Depends(get_db)):
254256

255257

256258
@app.get("/api/archives/{id}/files")
257-
def extract_archive(id: str, force: bool, db: Session = Depends(get_db)):
259+
def extract_archive(id: str, force: bool = True, db: Session = Depends(get_db)):
258260
a = db.get(Archive, id)
259261
if a is None:
260262
return JSONResponse({"operation": "", "error": "This ID doesn't exist on the server.", "success": 0}, status.HTTP_400_BAD_REQUEST)
@@ -336,6 +338,10 @@ def delete_archive(id: str, db: Session = Depends(get_db)):
336338
"filename": str(p)
337339
}
338340

341+
@app.post("/api/archives/{id}/extract") # Deprecated but used by Ichaival
342+
def extract_archive(id: str):
343+
return RedirectResponse(f'/api/archives/{id}/files', status_code=status.HTTP_303_SEE_OTHER)
344+
339345

340346
# Database API
341347

@@ -392,8 +398,9 @@ def get_all_categories(db: Session = Depends(get_db)):
392398

393399

394400
@app.put("/api/categories")
395-
def create_category(name: str, pinned: bool = False, search: Union[str, None] = None, db: Session = Depends(get_db)):
396-
if len(search) == 0: search = None
401+
def create_category(name: Annotated[str, Form()] = None, name2: Annotated[str, Query(alias="name")] = None, pinned: bool = False, search: Union[str, None] = None, db: Session = Depends(get_db)):
402+
if name is None: name = name2
403+
if not search is None and len(search) == 0: search = None
397404
c = Category(name=name, pinned=pinned, search=search)
398405
db.add(c)
399406
db.commit()
@@ -508,7 +515,7 @@ def info():
508515
"name": "ComicLib",
509516
"motd": "Welcome to the library powered by ComicLib!",
510517
"version": __version__,
511-
"version_name": "Kaosu",
518+
"version_name": "ComicLib",
512519
"version_desc": "Ababababa",
513520
"total_pages_read": "0",
514521
"has_password": "0",

docs/en/docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<p align="center"><sup>Manage, read and share your comic/manga library</sup></p>
33

44
## ✨ Features
5-
- 📁 Support multiple archive formats
5+
- 📁 Support [multiple archive formats](supported-formats.md)
66
- 🏷️ Support tag and category metadata import and management
77
- 🔌 Support plugins
88
- 🖼️ Support JPEG XL

docs/zh/docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<p align="center"><sup>管理、阅读、分享你的漫画库</sup></p>
33

44
## ✨ 特点
5-
- 📁 支持多种存档格式
5+
- 📁 支持[多种存档格式](supported-formats.md)
66
- 🏷️ 支持 tag 和分类元数据导入和管理
77
- 🔌 支持[插件](scanner.md)
88
- 🖼️ 支持 JPEG XL

0 commit comments

Comments
 (0)