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(
|
||||
meta_info=MetaInfo(title=torrent_in.title, subtitle=torrent_in.description),
|
||||
media_info=MediaInfo().from_dict(media_in.dict()),
|
||||
torrent_info=TorrentInfo(**torrent_in.dict())
|
||||
meta_info=metainfo,
|
||||
media_info=mediainfo,
|
||||
torrent_info=torrentinfo
|
||||
)
|
||||
did = DownloadChain().download_single(context=context, userid=current_user.name)
|
||||
return schemas.Response(success=True if did else False, data={
|
||||
|
@ -55,11 +55,14 @@ class TorrentInfo:
|
||||
# 种子优先级
|
||||
pri_order: int = 0
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.labels = []
|
||||
for key, value in kwargs.items():
|
||||
if hasattr(self, key) and value is not None:
|
||||
setattr(self, key, value)
|
||||
def from_dict(self, data: dict):
|
||||
"""
|
||||
从字典中初始化
|
||||
"""
|
||||
for key, value in data.items():
|
||||
if key in ['volume_factor']:
|
||||
continue
|
||||
setattr(self, key, value)
|
||||
|
||||
@staticmethod
|
||||
def get_free_string(upload_volume_factor: float, download_volume_factor: float) -> str:
|
||||
@ -159,9 +162,9 @@ class MediaInfo:
|
||||
从字典中初始化
|
||||
"""
|
||||
for key, value in data.items():
|
||||
attr = getattr(self, key, None)
|
||||
if attr and not isinstance(attr, property):
|
||||
setattr(self, key, value)
|
||||
if key in ["title_year", "detail_link", "stars", "vote_star"]:
|
||||
continue
|
||||
setattr(self, key, value)
|
||||
if isinstance(self.type, str):
|
||||
self.type = MediaType(self.type)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user