From f296021d9388919b7354dbfce0eb9820c48fb26f Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Mon, 30 Oct 2023 20:29:00 +0800 Subject: [PATCH] fix: analyser api error. eps complete logic. --- Dockerfile | 1 - backend/src/module/database/bangumi.py | 4 +++- backend/src/module/rss/analyser.py | 30 ++++++++++++++++---------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 02c9995c0..af83d1970 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,6 @@ RUN set -ex && \ shadow \ tini \ openssl \ - busybox-suid \ tzdata && \ python3 -m pip install --no-cache-dir --upgrade pip && \ sed -i '/bcrypt/d' requirements.txt && \ diff --git a/backend/src/module/database/bangumi.py b/backend/src/module/database/bangumi.py index ae4ed366a..b484c6b0e 100644 --- a/backend/src/module/database/bangumi.py +++ b/backend/src/module/database/bangumi.py @@ -144,7 +144,9 @@ def not_complete(self) -> list[Bangumi]: # Find eps_complete = False # use `false()` to avoid E712 checking # see: https://docs.astral.sh/ruff/rules/true-false-comparison/ - condition = select(Bangumi).where(Bangumi.eps_collect == false()) + condition = select(Bangumi).where( + and_(Bangumi.eps_collect == false(), Bangumi.deleted == false()) + ) datas = self.session.exec(condition).all() return datas diff --git a/backend/src/module/rss/analyser.py b/backend/src/module/rss/analyser.py index af1bc79a2..81fd0e36a 100644 --- a/backend/src/module/rss/analyser.py +++ b/backend/src/module/rss/analyser.py @@ -82,14 +82,22 @@ def rss_to_data( def link_to_data(self, rss: RSSItem) -> Bangumi | ResponseModel: torrents = self.get_rss_torrents(rss.url, False) - for torrent in torrents: - data = self.torrent_to_data(torrent, rss) - if data: - return data - else: - return ResponseModel( - status=False, - status_code=406, - msg_en="Cannot parse this link.", - msg_zh="无法解析此链接。", - ) + if not torrents: + for torrent in torrents: + data = self.torrent_to_data(torrent, rss) + if data: + return data + else: + return ResponseModel( + status=False, + status_code=406, + msg_en="Cannot parse this link.", + msg_zh="无法解析此链接。", + ) + else: + return ResponseModel( + status=False, + status_code=406, + msg_en="Cannot find any torrent.", + msg_zh="无法找到种子。", + )