mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-06-11 10:40:18 +08:00
fix(openlist): request full directory pages
This commit is contained in:
@@ -16,6 +16,10 @@ from app.utils.singleton import WeakSingleton
|
||||
from app.utils.url import UrlUtils
|
||||
|
||||
|
||||
# OpenList/AList 在 per_page<=0 时会退回后端默认 200,显式指定最大页大小避免大目录被截断。
|
||||
OPENLIST_MAX_LIST_PAGE_SIZE = 500
|
||||
|
||||
|
||||
class Alist(StorageBase, metaclass=WeakSingleton):
|
||||
"""
|
||||
Openlist相关操作
|
||||
@@ -201,6 +205,8 @@ class Alist(StorageBase, metaclass=WeakSingleton):
|
||||
return []
|
||||
items = []
|
||||
current_page = page
|
||||
auto_page = per_page <= 0
|
||||
effective_per_page = OPENLIST_MAX_LIST_PAGE_SIZE if auto_page else per_page
|
||||
while True:
|
||||
resp = RequestUtils(headers=self.__get_header_with_token()).post_res(
|
||||
self.__get_api_url("/api/fs/list"),
|
||||
@@ -208,7 +214,7 @@ class Alist(StorageBase, metaclass=WeakSingleton):
|
||||
"path": fileitem.path,
|
||||
"password": password,
|
||||
"page": current_page,
|
||||
"per_page": per_page,
|
||||
"per_page": effective_per_page,
|
||||
"refresh": refresh,
|
||||
},
|
||||
)
|
||||
@@ -267,7 +273,8 @@ class Alist(StorageBase, metaclass=WeakSingleton):
|
||||
)
|
||||
return []
|
||||
|
||||
page_content = result["data"].get("content") or []
|
||||
page_data = result["data"]
|
||||
page_content = page_data.get("content") or []
|
||||
items.extend(
|
||||
[
|
||||
schemas.FileItem(
|
||||
@@ -286,12 +293,16 @@ class Alist(StorageBase, metaclass=WeakSingleton):
|
||||
]
|
||||
)
|
||||
|
||||
if per_page > 0:
|
||||
if not auto_page:
|
||||
return items
|
||||
|
||||
total = result["data"].get("total") or 0
|
||||
total = page_data.get("filtered_total") or page_data.get("total") or 0
|
||||
pages_total = page_data.get("pages_total") or 0
|
||||
has_more = page_data.get("has_more")
|
||||
if not page_content or len(items) >= total:
|
||||
return items
|
||||
if has_more is False or (pages_total and current_page >= pages_total):
|
||||
return items
|
||||
|
||||
current_page += 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user