mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-09 01:16:50 +08:00
Merge pull request #3196 from wikrin/fix
This commit is contained in:
@@ -256,7 +256,7 @@ class DownloadChain(ChainBase):
|
|||||||
download_dir = Path(save_path)
|
download_dir = Path(save_path)
|
||||||
else:
|
else:
|
||||||
# 根据媒体信息查询下载目录配置
|
# 根据媒体信息查询下载目录配置
|
||||||
dir_info = self.directoryhelper.get_dir(_media)
|
dir_info = self.directoryhelper.get_dir(_media, storage="local")
|
||||||
# 拼装子目录
|
# 拼装子目录
|
||||||
if dir_info:
|
if dir_info:
|
||||||
# 一级目录
|
# 一级目录
|
||||||
|
|||||||
@@ -392,13 +392,19 @@ class TransferChain(ChainBase):
|
|||||||
download_hash = download_file.download_hash
|
download_hash = download_file.download_hash
|
||||||
|
|
||||||
# 查询整理目标目录
|
# 查询整理目标目录
|
||||||
if not target_directory and not target_path:
|
if not target_directory:
|
||||||
if src_match:
|
if src_match:
|
||||||
# 按源目录匹配,以便找到更合适的目录配置
|
# 按源目录匹配,以便找到更合适的目录配置
|
||||||
target_directory = self.directoryhelper.get_dir(file_mediainfo,
|
target_directory = self.directoryhelper.get_dir(media=file_mediainfo,
|
||||||
storage=file_item.storage,
|
storage=file_item.storage,
|
||||||
src_path=file_path,
|
src_path=file_path,
|
||||||
target_storage=target_storage)
|
target_storage=target_storage)
|
||||||
|
elif target_path:
|
||||||
|
# 指定目标路径,`手动整理`场景下使用,忽略源目录匹配,使用指定目录匹配
|
||||||
|
target_directory = self.directoryhelper.get_dir(media=file_mediainfo,
|
||||||
|
storage=target_storage,
|
||||||
|
target_path=target_path,
|
||||||
|
target_storage=target_storage)
|
||||||
else:
|
else:
|
||||||
# 未指定目标路径,根据媒体信息获取目标目录
|
# 未指定目标路径,根据媒体信息获取目标目录
|
||||||
target_directory = self.directoryhelper.get_dir(file_mediainfo,
|
target_directory = self.directoryhelper.get_dir(file_mediainfo,
|
||||||
|
|||||||
+4
-10
@@ -50,8 +50,8 @@ class DirectoryHelper:
|
|||||||
return [d for d in self.get_library_dirs() if d.library_storage == "local"]
|
return [d for d in self.get_library_dirs() if d.library_storage == "local"]
|
||||||
|
|
||||||
def get_dir(self, media: MediaInfo,
|
def get_dir(self, media: MediaInfo,
|
||||||
storage: str = "local", fileitem: schemas.FileItem = None, src_path: Path = None,
|
storage: str = None, src_path: Path = None,
|
||||||
target_storage: str = "local", dest_path: Path = None
|
target_storage: str = None, dest_path: Path = None
|
||||||
) -> Optional[schemas.TransferDirectoryConf]:
|
) -> Optional[schemas.TransferDirectoryConf]:
|
||||||
"""
|
"""
|
||||||
根据媒体信息获取下载目录、媒体库目录配置
|
根据媒体信息获取下载目录、媒体库目录配置
|
||||||
@@ -69,7 +69,7 @@ class DirectoryHelper:
|
|||||||
media_type = media.type.value
|
media_type = media.type.value
|
||||||
dirs = self.get_dirs()
|
dirs = self.get_dirs()
|
||||||
# 已匹配的目录
|
# 已匹配的目录
|
||||||
matched_dirs = []
|
matched_dirs: List[schemas.TransferDirectoryConf] = []
|
||||||
# 按照配置顺序查找
|
# 按照配置顺序查找
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
# 没有启用整理的目录
|
# 没有启用整理的目录
|
||||||
@@ -81,17 +81,11 @@ class DirectoryHelper:
|
|||||||
# 目标存储类型不匹配
|
# 目标存储类型不匹配
|
||||||
if target_storage and d.library_storage != target_storage:
|
if target_storage and d.library_storage != target_storage:
|
||||||
continue
|
continue
|
||||||
# 有文件项时,源存储不匹配
|
|
||||||
if fileitem and fileitem.storage != d.storage:
|
|
||||||
continue
|
|
||||||
# 有文件项时,文件项不匹配下载目录
|
|
||||||
if fileitem and not Path(fileitem.path).is_relative_to(d.download_path):
|
|
||||||
continue
|
|
||||||
# 有源目录时,源目录不匹配下载目录
|
# 有源目录时,源目录不匹配下载目录
|
||||||
if src_path and not src_path.is_relative_to(d.download_path):
|
if src_path and not src_path.is_relative_to(d.download_path):
|
||||||
continue
|
continue
|
||||||
# 有目标目录时,目标目录不匹配媒体库目录
|
# 有目标目录时,目标目录不匹配媒体库目录
|
||||||
if dest_path and not dest_path.is_relative_to(d.library_path):
|
if dest_path and dest_path != Path(d.library_path):
|
||||||
continue
|
continue
|
||||||
# 目录类型为全部的,符合条件
|
# 目录类型为全部的,符合条件
|
||||||
if not d.media_type:
|
if not d.media_type:
|
||||||
|
|||||||
Reference in New Issue
Block a user