fix: support non-local filesystem operations for default dir and subtitles

This commit is contained in:
stkevintan
2025-11-28 14:55:01 +08:00
parent 10c26de7cb
commit e51b679380
4 changed files with 58 additions and 23 deletions
+4 -2
View File
@@ -707,17 +707,19 @@ class ChainBase(metaclass=ABCMeta):
cookie=cookie, episodes=episodes, category=category, label=label,
downloader=downloader)
def download_added(self, context: Context, download_dir: Path, torrent_content: Union[str, bytes] = None) -> None:
def download_added(self, context: Context, download_dir: Path, storage: str, torrent_content: Union[str, bytes] = None) -> None:
"""
添加下载任务成功后,从站点下载字幕,保存到下载目录
:param context: 上下文,包括识别信息、媒体信息、种子信息
:param download_dir: 下载目录
:param storage: 存储类型
:param torrent_content: 种子内容,如果有则直接使用该内容,否则从context中获取种子文件路径
:return: None,该方法可被多个模块同时处理
"""
return self.run_module("download_added", context=context,
torrent_content=torrent_content,
download_dir=download_dir)
download_dir=download_dir,
storage=storage)
def list_torrents(self, status: TorrentStatus = None,
hashs: Union[list, str] = None,
+7 -2
View File
@@ -232,13 +232,18 @@ class DownloadChain(ChainBase):
# 获取种子文件的文件夹名和文件清单
_folder_name, _file_list = TorrentHelper().get_fileinfo_from_torrent_content(torrent_content)
storage = 'local'
# 下载目录
if save_path:
# 下载目录使用自定义的
download_dir = Path(save_path)
# Check if the download_dir matches any configured dirs
dir_info = DirectoryHelper().get_dir(dest_path=download_dir)
storage = dir_info.library_storage if dir_info else storage
else:
# 根据媒体信息查询下载目录配置
dir_info = DirectoryHelper().get_dir(_media, storage="local", include_unsorted=True)
dir_info = DirectoryHelper().get_dir(_media, include_unsorted=True)
storage = dir_info.library_storage if dir_info else storage
# 拼装子目录
if dir_info:
# 一级目录
@@ -358,7 +363,7 @@ class DownloadChain(ChainBase):
username=username,
)
# 下载成功后处理
self.download_added(context=context, download_dir=download_dir, torrent_content=torrent_content)
self.download_added(context=context, download_dir=download_dir, storage=storage, torrent_content=torrent_content)
# 广播事件
self.eventmanager.send_event(EventType.DownloadAdded, {
"hash": _hash,