mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix _path_to_id
This commit is contained in:
@@ -236,9 +236,12 @@ class U115Pan(StorageBase, metaclass=Singleton):
|
|||||||
"""
|
"""
|
||||||
路径转FID(带缓存机制)
|
路径转FID(带缓存机制)
|
||||||
"""
|
"""
|
||||||
|
# 根目录
|
||||||
|
if path == "/":
|
||||||
|
return 0
|
||||||
if len(path) > 1 and path.endswith("/"):
|
if len(path) > 1 and path.endswith("/"):
|
||||||
path = path[:-1]
|
path = path[:-1]
|
||||||
# 命中缓存
|
# 检查缓存
|
||||||
if path in self._id_cache:
|
if path in self._id_cache:
|
||||||
return self._id_cache[path]
|
return self._id_cache[path]
|
||||||
# 逐级查找缓存
|
# 逐级查找缓存
|
||||||
@@ -252,18 +255,26 @@ class U115Pan(StorageBase, metaclass=Singleton):
|
|||||||
# 计算相对路径
|
# 计算相对路径
|
||||||
rel_path = Path(path).relative_to(parent_path)
|
rel_path = Path(path).relative_to(parent_path)
|
||||||
for part in Path(rel_path).parts:
|
for part in Path(rel_path).parts:
|
||||||
resp = self._request_api(
|
offset = 0
|
||||||
"GET",
|
while True:
|
||||||
"/open/ufile/files",
|
resp = self._request_api(
|
||||||
"data",
|
"GET",
|
||||||
params={"cid": current_id, "limit": 1000, "cur": True, "show_dir": 1}
|
"/open/ufile/files",
|
||||||
)
|
"data",
|
||||||
for item in resp:
|
params={"cid": current_id, "limit": 1000, "offset": offset, "cur": True, "show_dir": 1}
|
||||||
if item["fn"] == part:
|
)
|
||||||
current_id = item["fid"]
|
if not resp:
|
||||||
break
|
break
|
||||||
else:
|
for item in resp:
|
||||||
raise FileNotFoundError(f"【115】路径不存在: {path}")
|
if item["fn"] == part:
|
||||||
|
current_id = item["fid"]
|
||||||
|
break
|
||||||
|
if len(resp) < 1000:
|
||||||
|
break
|
||||||
|
offset += len(resp)
|
||||||
|
if not current_id:
|
||||||
|
raise FileNotFoundError(f"【115】{path} 不存在")
|
||||||
|
# 缓存路径
|
||||||
self._id_cache[path] = current_id
|
self._id_cache[path] = current_id
|
||||||
return current_id
|
return current_id
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user