From f7b96daa50d933198b107c59be679f4caa8bdc25 Mon Sep 17 00:00:00 2001 From: yubanmeiqin9048 <1414603524@qq.com> Date: Mon, 7 Aug 2023 21:01:47 +0800 Subject: [PATCH] fix to_dict --- app/core/context.py | 1 + app/schemas/transfer.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/core/context.py b/app/core/context.py index 7b568a51..7b47777a 100644 --- a/app/core/context.py +++ b/app/core/context.py @@ -549,6 +549,7 @@ class MediaInfo: dicts["type"] = self.type.value if self.type else None dicts["detail_link"] = self.detail_link dicts["title_year"] = self.title_year + dicts["tmdb_info"]["media_type"] = self.type.value if self.type else None return dicts def clear(self): diff --git a/app/schemas/transfer.py b/app/schemas/transfer.py index 7f95b3de..2f7f04b5 100644 --- a/app/schemas/transfer.py +++ b/app/schemas/transfer.py @@ -30,7 +30,6 @@ class DownloadingTorrent(BaseModel): dlspeed: Optional[str] = None media: Optional[dict] = {} - class TransferInfo(BaseModel): """ 文件转移结果信息 @@ -51,3 +50,12 @@ class TransferInfo(BaseModel): fail_list: Optional[list] = [] # 错误信息 message: Optional[str] = None + + def to_dict(self): + """ + 返回字典 + """ + dicts = vars(self).copy() # 创建一个字典的副本以避免修改原始数据 + dicts["path"] = str(self.path) if self.path else None + dicts["target_path"] = str(self.target_path) if self.target_path else None + return dicts \ No newline at end of file