1919from app .helper .directory import DirectoryHelper
2020from app .helper .torrent import TorrentHelper
2121from app .log import logger
22- from app .schemas import ExistMediaInfo , NotExistMediaInfo , DownloadingTorrent , Notification , ResourceSelectionEventData , \
22+ from app .schemas import ExistMediaInfo , FileURI , NotExistMediaInfo , DownloadingTorrent , Notification , ResourceSelectionEventData , \
2323 ResourceDownloadEventData
2424from app .schemas .types import MediaType , TorrentStatus , EventType , MessageChannel , NotificationType , ContentType , \
2525 ChainEventType
@@ -235,10 +235,7 @@ def download_single(self, context: Context,
235235 storage = 'local'
236236 # 下载目录
237237 if save_path :
238- uri = schemas .FileURI .from_uri (save_path )
239- # 下载目录使用自定义的
240- download_dir = Path (uri .path )
241- storage = uri .storage
238+ download_dir = Path (save_path )
242239 else :
243240 # 根据媒体信息查询下载目录配置
244241 dir_info = DirectoryHelper ().get_dir (_media , include_unsorted = True )
@@ -263,6 +260,8 @@ def download_single(self, context: Context,
263260 self .messagehelper .put (f"{ _media .type .value } { _media .title_year } 未找到下载目录!" ,
264261 title = "下载失败" , role = "system" )
265262 return None
263+ fileURI = FileURI (storage = storage , path = download_dir .as_posix ())
264+ download_dir = Path (fileURI .uri )
266265
267266 # 添加下载
268267 result : Optional [tuple ] = self .download (content = torrent_content ,
@@ -362,7 +361,7 @@ def download_single(self, context: Context,
362361 username = username ,
363362 )
364363 # 下载成功后处理
365- self .download_added (context = context , download_dir = download_dir , storage = storage , torrent_content = torrent_content )
364+ self .download_added (context = context , download_dir = download_dir , torrent_content = torrent_content )
366365 # 广播事件
367366 self .eventmanager .send_event (EventType .DownloadAdded , {
368367 "hash" : _hash ,
0 commit comments