From 88332aac5094ba97458f0c304ec8e34e20623875 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 1 Aug 2023 17:49:34 +0800 Subject: [PATCH] fix bug --- app/api/endpoints/subscribe.py | 6 +++++- app/chain/transfer.py | 16 ++++++++++++---- app/db/models/downloadhistory.py | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/api/endpoints/subscribe.py b/app/api/endpoints/subscribe.py index f21158a7..ed43fb69 100644 --- a/app/api/endpoints/subscribe.py +++ b/app/api/endpoints/subscribe.py @@ -95,7 +95,11 @@ def update_subscribe( return schemas.Response(success=False, message="订阅不存在") if subscribe_in.sites: subscribe_in.sites = json.dumps(subscribe_in.sites) - subscribe.update(db, subscribe_in.dict()) + # 避免更新缺失集数 + subscribe_dict = subscribe_in.dict() + if not subscribe_in.lack_episode: + subscribe_dict.pop("lack_episode") + subscribe.update(db, subscribe_dict) return schemas.Response(success=True) diff --git a/app/chain/transfer.py b/app/chain/transfer.py index 7f7c3aa8..8be95baf 100644 --- a/app/chain/transfer.py +++ b/app/chain/transfer.py @@ -104,8 +104,16 @@ class TransferChain(ChainBase): # 查询下载记录识别情况 downloadhis: DownloadHistory = self.downloadhis.get_by_hash(torrent.hash) if downloadhis: - mtype = MediaType.TV if downloadhis.type == MediaType.TV.value else MediaType.MOVIE - mediainfo = self.recognize_media(mtype=mtype, tmdbid=downloadhis.tmdbid) + # 类型 + mtype = MediaType(downloadhis.type) + # 补充剧集信息 + if mtype == MediaType.TV \ + and ((not meta.season_list and downloadhis.seasons) + or (not meta.episode_list and downloadhis.episodes)): + meta = MetaInfo(f"{title} {downloadhis.seasons} {downloadhis.episodes}") + # 按TMDBID识别 + mediainfo = self.recognize_media(mtype=mtype, + tmdbid=downloadhis.tmdbid) else: # 使用标题识别媒体信息 mediainfo: MediaInfo = self.recognize_media(meta=meta) @@ -229,8 +237,8 @@ class TransferChain(ChainBase): msg_str = f"{msg_str},以下文件处理失败:\n{transferinfo.message}" # 发送 self.post_message(Notification( - mtype=NotificationType.Organize, - title=msg_title, text=msg_str, image=mediainfo.get_message_image())) + mtype=NotificationType.Organize, + title=msg_title, text=msg_str, image=mediainfo.get_message_image())) @staticmethod def delete_files(path: Path): diff --git a/app/db/models/downloadhistory.py b/app/db/models/downloadhistory.py index ab10a34e..918312bc 100644 --- a/app/db/models/downloadhistory.py +++ b/app/db/models/downloadhistory.py @@ -22,7 +22,7 @@ class DownloadHistory(Base): tvdbid = Column(Integer) doubanid = Column(String) # Sxx - seasons = Column(Integer) + seasons = Column(String) # Exx episodes = Column(String) # 海报