From 5340e3a0a7cdc6aca81580caadc84f75207f32a7 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 28 Jul 2025 16:55:22 +0800 Subject: [PATCH] fix --- app/chain/transfer.py | 2 +- app/modules/filemanager/__init__.py | 2 +- app/modules/filemanager/storages/alipan.py | 2 +- app/modules/filemanager/storages/local.py | 4 ++-- app/modules/filemanager/storages/rclone.py | 2 +- app/modules/filemanager/storages/u115.py | 4 ++-- app/modules/filemanager/transhandler.py | 2 +- app/modules/plex/plex.py | 12 ++++++------ app/monitor.py | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/chain/transfer.py b/app/chain/transfer.py index f1f120ab..901488ce 100755 --- a/app/chain/transfer.py +++ b/app/chain/transfer.py @@ -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, diff --git a/app/modules/filemanager/__init__.py b/app/modules/filemanager/__init__.py index 44bff9bc..5ecf1cfa 100644 --- a/app/modules/filemanager/__init__.py +++ b/app/modules/filemanager/__init__.py @@ -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: """ diff --git a/app/modules/filemanager/storages/alipan.py b/app/modules/filemanager/storages/alipan.py index 7bd79703..8d77091d 100644 --- a/app/modules/filemanager/storages/alipan.py +++ b/app/modules/filemanager/storages/alipan.py @@ -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: diff --git a/app/modules/filemanager/storages/local.py b/app/modules/filemanager/storages/local.py index f4078273..3f08056a 100644 --- a/app/modules/filemanager/storages/local.py +++ b/app/modules/filemanager/storages/local.py @@ -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, diff --git a/app/modules/filemanager/storages/rclone.py b/app/modules/filemanager/storages/rclone.py index 51c6c87c..8822e12c 100644 --- a/app/modules/filemanager/storages/rclone.py +++ b/app/modules/filemanager/storages/rclone.py @@ -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() diff --git a/app/modules/filemanager/storages/u115.py b/app/modules/filemanager/storages/u115.py index 56b97f45..77ffccb5 100644 --- a/app/modules/filemanager/storages/u115.py +++ b/app/modules/filemanager/storages/u115.py @@ -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, diff --git a/app/modules/filemanager/transhandler.py b/app/modules/filemanager/transhandler.py index 2091bc8f..b40ca3f9 100644 --- a/app/modules/filemanager/transhandler.py +++ b/app/modules/filemanager/transhandler.py @@ -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", diff --git a/app/modules/plex/plex.py b/app/modules/plex/plex.py index 7ab7871e..622097b3 100644 --- a/app/modules/plex/plex.py +++ b/app/modules/plex/plex.py @@ -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]: """ diff --git a/app/monitor.py b/app/monitor.py index 53be0444..164debc6 100644 --- a/app/monitor.py +++ b/app/monitor.py @@ -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,