This commit is contained in:
jxxghp
2025-07-28 16:55:22 +08:00
parent 70dd8f0f1d
commit 5340e3a0a7
9 changed files with 17 additions and 17 deletions

View File

@@ -890,7 +890,7 @@ class TransferChain(ChainBase, metaclass=Singleton):
state, errmsg = self.do_transfer(
fileitem=FileItem(
storage="local",
path=str(file_path).replace("\\", "/"),
path=file_path.as_posix(),
type="dir" if not file_path.is_file() else "file",
name=file_path.name,
size=file_path.stat().st_size,

View File

@@ -165,7 +165,7 @@ class FileManagerModule(_ModuleBase):
episodes_info=episodes_info,
file_ext=Path(meta.title).suffix)
)
return str(path)
return path.as_posix() if path else ""
def save_config(self, storage: str, conf: Dict) -> None:
"""

View File

@@ -783,7 +783,7 @@ class AliPan(StorageBase, metaclass=WeakSingleton):
"/adrive/v1.0/openFile/get_by_path",
json={
"drive_id": drive_id or self._default_drive_id,
"file_path": str(path)
"file_path": path.as_posix()
}
)
if not resp:

View File

@@ -44,7 +44,7 @@ class LocalStorage(StorageBase):
return schemas.FileItem(
storage=self.schema.value,
type="file",
path=str(path).replace("\\", "/"),
path=path.as_posix(),
name=path.name,
basename=path.stem,
extension=path.suffix[1:],
@@ -59,7 +59,7 @@ class LocalStorage(StorageBase):
return schemas.FileItem(
storage=self.schema.value,
type="dir",
path=str(path).replace("\\", "/") + "/",
path=path.as_posix() + "/",
name=path.name,
basename=path.stem,
modify_time=path.stat().st_mtime,

View File

@@ -269,7 +269,7 @@ class Rclone(StorageBase):
retcode = subprocess.run(
[
'rclone', 'copyto',
str(path),
path.as_posix(),
f'MP:{new_path}'
],
startupinfo=self.__get_hidden_shell()

View File

@@ -672,7 +672,7 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
"/open/folder/get_info",
"data",
data={
"path": str(path)
"path": path.as_posix()
}
)
if not resp:
@@ -680,7 +680,7 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
return schemas.FileItem(
storage=self.schema.value,
fileid=str(resp["file_id"]),
path=str(path) + ("/" if resp["file_category"] == "0" else ""),
path=path.as_posix() + ("/" if resp["file_category"] == "0" else ""),
type="file" if resp["file_category"] == "1" else "dir",
name=resp["file_name"],
basename=Path(resp["file_name"]).stem,

View File

@@ -330,7 +330,7 @@ class TransHandler:
"""
return FileItem(
storage=target_storage,
path=str(_path).replace("\\", "/"),
path=_path.as_posix(),
name=_path.name,
basename=_path.stem,
type="file",

View File

@@ -379,7 +379,7 @@ class Plex:
file_path = item.target_path
lib_key, path = self.__find_librarie(file_path, self._libraries)
# 如果存在同一剧集的多集,key(path)相同会合并
result_dict[path] = lib_key
result_dict[path.as_posix()] = lib_key
if "" in result_dict:
# 如果有匹配失败的,刷新整个库
self._plex.library.update()
@@ -387,12 +387,12 @@ class Plex:
# 否则一个一个刷新
for path, lib_key in result_dict.items():
logger.info(f"刷新媒体库:{lib_key} - {path}")
self._plex.query(f'/library/sections/{lib_key}/refresh?path={quote_plus(str(Path(path).parent))}')
self._plex.query(f'/library/sections/{lib_key}/refresh?path={quote_plus(Path(path).parent.as_posix())}')
return None
return None
@staticmethod
def __find_librarie(path: Path, libraries: List[Any]) -> Tuple[str, str]:
def __find_librarie(path: Path, libraries: List[Any]) -> Tuple[str, Optional[Path]]:
"""
判断这个path属于哪个媒体库
多个媒体库配置的目录不应有重复和嵌套,
@@ -407,17 +407,17 @@ class Plex:
return _path.parts[:len(_parent.parts)] == _parent.parts
if path is None:
return "", ""
return "", None
try:
for lib in libraries:
if hasattr(lib, "locations") and lib.locations:
for location in lib.locations:
if is_subpath(path, Path(location)):
return lib.key, str(path)
return lib.key, path
except Exception as err:
logger.error(f"查找媒体库出错:{str(err)}")
return "", ""
return "", None
def get_iteminfo(self, itemid: str) -> Optional[schemas.MediaServerItem]:
"""

View File

@@ -724,7 +724,7 @@ class Monitor(metaclass=Singleton):
"""
判断是否蓝光原盘目录内的子目录或文件
"""
return True if re.search(r"BDMV[/\\]STREAM", str(_path), re.IGNORECASE) else False
return True if re.search(r"BDMV/STREAM", _path.as_posix(), re.IGNORECASE) else False
def __get_bluray_dir(_path: Path) -> Optional[Path]:
"""
@@ -755,7 +755,7 @@ class Monitor(metaclass=Singleton):
TransferChain().do_transfer(
fileitem=FileItem(
storage=storage,
path=str(event_path).replace("\\", "/"),
path=event_path.as_posix(),
type="file",
name=event_path.name,
basename=event_path.stem,