mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
fix download api
This commit is contained in:
@@ -28,6 +28,7 @@ def list(
|
|||||||
def download(
|
def download(
|
||||||
media_in: schemas.MediaInfo,
|
media_in: schemas.MediaInfo,
|
||||||
torrent_in: schemas.TorrentInfo,
|
torrent_in: schemas.TorrentInfo,
|
||||||
|
downloader: str = None,
|
||||||
current_user: User = Depends(get_current_active_user)) -> Any:
|
current_user: User = Depends(get_current_active_user)) -> Any:
|
||||||
"""
|
"""
|
||||||
添加下载任务(含媒体信息)
|
添加下载任务(含媒体信息)
|
||||||
@@ -46,7 +47,7 @@ def download(
|
|||||||
media_info=mediainfo,
|
media_info=mediainfo,
|
||||||
torrent_info=torrentinfo
|
torrent_info=torrentinfo
|
||||||
)
|
)
|
||||||
did = DownloadChain().download_single(context=context, username=current_user.name)
|
did = DownloadChain().download_single(context=context, username=current_user.name, downloader=downloader)
|
||||||
if not did:
|
if not did:
|
||||||
return schemas.Response(success=False, message="任务添加失败")
|
return schemas.Response(success=False, message="任务添加失败")
|
||||||
return schemas.Response(success=True, data={
|
return schemas.Response(success=True, data={
|
||||||
@@ -57,6 +58,7 @@ def download(
|
|||||||
@router.post("/add", summary="添加下载(不含媒体信息)", response_model=schemas.Response)
|
@router.post("/add", summary="添加下载(不含媒体信息)", response_model=schemas.Response)
|
||||||
def add(
|
def add(
|
||||||
torrent_in: schemas.TorrentInfo,
|
torrent_in: schemas.TorrentInfo,
|
||||||
|
downloader: str = None,
|
||||||
current_user: User = Depends(get_current_active_user)) -> Any:
|
current_user: User = Depends(get_current_active_user)) -> Any:
|
||||||
"""
|
"""
|
||||||
添加下载任务(不含媒体信息)
|
添加下载任务(不含媒体信息)
|
||||||
@@ -76,7 +78,7 @@ def add(
|
|||||||
media_info=mediainfo,
|
media_info=mediainfo,
|
||||||
torrent_info=torrentinfo
|
torrent_info=torrentinfo
|
||||||
)
|
)
|
||||||
did = DownloadChain().download_single(context=context, username=current_user.name)
|
did = DownloadChain().download_single(context=context, username=current_user.name, downloader=downloader)
|
||||||
if not did:
|
if not did:
|
||||||
return schemas.Response(success=False, message="任务添加失败")
|
return schemas.Response(success=False, message="任务添加失败")
|
||||||
return schemas.Response(success=True, data={
|
return schemas.Response(success=True, data={
|
||||||
|
|||||||
@@ -206,7 +206,8 @@ class DownloadChain(ChainBase):
|
|||||||
channel: MessageChannel = None, source: str = None,
|
channel: MessageChannel = None, source: str = None,
|
||||||
save_path: str = None,
|
save_path: str = None,
|
||||||
userid: Union[str, int] = None,
|
userid: Union[str, int] = None,
|
||||||
username: str = None) -> Optional[str]:
|
username: str = None,
|
||||||
|
downloader: str = None) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
下载及发送通知
|
下载及发送通知
|
||||||
:param context: 资源上下文
|
:param context: 资源上下文
|
||||||
@@ -217,6 +218,7 @@ class DownloadChain(ChainBase):
|
|||||||
:param save_path: 保存路径
|
:param save_path: 保存路径
|
||||||
:param userid: 用户ID
|
:param userid: 用户ID
|
||||||
:param username: 调用下载的用户名/插件名
|
:param username: 调用下载的用户名/插件名
|
||||||
|
:param downloader: 下载器
|
||||||
"""
|
"""
|
||||||
_torrent = context.torrent_info
|
_torrent = context.torrent_info
|
||||||
_media = context.media_info
|
_media = context.media_info
|
||||||
@@ -282,7 +284,8 @@ class DownloadChain(ChainBase):
|
|||||||
cookie=_torrent.site_cookie,
|
cookie=_torrent.site_cookie,
|
||||||
episodes=episodes,
|
episodes=episodes,
|
||||||
download_dir=download_dir,
|
download_dir=download_dir,
|
||||||
category=_media.category)
|
category=_media.category,
|
||||||
|
downloader=downloader)
|
||||||
if result:
|
if result:
|
||||||
_downloader, _hash, error_msg = result
|
_downloader, _hash, error_msg = result
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user