fix download
This commit is contained in:
parent
5690ee9bd6
commit
f20c133c81
@ -33,10 +33,19 @@ async def add_downloading(
|
|||||||
"""
|
"""
|
||||||
添加下载任务
|
添加下载任务
|
||||||
"""
|
"""
|
||||||
|
# 元数据
|
||||||
|
metainfo = MetaInfo(title=torrent_in.title, subtitle=torrent_in.description)
|
||||||
|
# 媒体信息
|
||||||
|
mediainfo = MediaInfo()
|
||||||
|
mediainfo.from_dict(media_in.dict())
|
||||||
|
# 种子信息
|
||||||
|
torrentinfo = TorrentInfo()
|
||||||
|
torrentinfo.from_dict(torrent_in.dict())
|
||||||
|
# 上下文
|
||||||
context = Context(
|
context = Context(
|
||||||
meta_info=MetaInfo(title=torrent_in.title, subtitle=torrent_in.description),
|
meta_info=metainfo,
|
||||||
media_info=MediaInfo().from_dict(media_in.dict()),
|
media_info=mediainfo,
|
||||||
torrent_info=TorrentInfo(**torrent_in.dict())
|
torrent_info=torrentinfo
|
||||||
)
|
)
|
||||||
did = DownloadChain().download_single(context=context, userid=current_user.name)
|
did = DownloadChain().download_single(context=context, userid=current_user.name)
|
||||||
return schemas.Response(success=True if did else False, data={
|
return schemas.Response(success=True if did else False, data={
|
||||||
|
@ -55,10 +55,13 @@ class TorrentInfo:
|
|||||||
# 种子优先级
|
# 种子优先级
|
||||||
pri_order: int = 0
|
pri_order: int = 0
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def from_dict(self, data: dict):
|
||||||
self.labels = []
|
"""
|
||||||
for key, value in kwargs.items():
|
从字典中初始化
|
||||||
if hasattr(self, key) and value is not None:
|
"""
|
||||||
|
for key, value in data.items():
|
||||||
|
if key in ['volume_factor']:
|
||||||
|
continue
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -159,8 +162,8 @@ class MediaInfo:
|
|||||||
从字典中初始化
|
从字典中初始化
|
||||||
"""
|
"""
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
attr = getattr(self, key, None)
|
if key in ["title_year", "detail_link", "stars", "vote_star"]:
|
||||||
if attr and not isinstance(attr, property):
|
continue
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
if isinstance(self.type, str):
|
if isinstance(self.type, str):
|
||||||
self.type = MediaType(self.type)
|
self.type = MediaType(self.type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user