From 0e60c976be1f1011c78c130c5c8b4f8cbac78812 Mon Sep 17 00:00:00 2001 From: thsrite Date: Sun, 28 Apr 2024 10:21:42 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E9=BB=98=E8=AE=A4=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E8=A7=84=E5=88=99=E6=94=AF=E6=8C=81=E6=9C=80=E5=B0=91=E5=81=9A?= =?UTF-8?q?=E7=A7=8D=E4=BA=BA=E6=95=B0=E7=94=9F=E6=95=88=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=97=B6=E9=97=B4=EF=BC=8C=E9=98=B2=E6=AD=A2=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E6=8E=89=E5=88=B0=E6=9C=80=E6=96=B0=E5=8F=91=E5=B8=83=E7=9A=84?= =?UTF-8?q?=E7=A7=8D=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helper/torrent.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/app/helper/torrent.py b/app/helper/torrent.py index 526bc012..9775a0be 100644 --- a/app/helper/torrent.py +++ b/app/helper/torrent.py @@ -322,6 +322,21 @@ class TorrentHelper(metaclass=Singleton): logger.error(f"解析大小范围失败:{str(e)} - {traceback.format_exc()}") return 0, 0 + def __get_pubminutes(pubdate: str) -> float: + """ + 将字符串转换为时间,并计算与当前时间差)(分钟) + """ + try: + if not pubdate: + return 0 + pubdate = pubdate.replace("T", " ").replace("Z", "") + pubdate = datetime.datetime.strptime(pubdate, "%Y-%m-%d %H:%M:%S") + now = datetime.datetime.now() + return (now - pubdate).total_seconds() // 60 + except Exception as e: + print(str(e)) + return 0 + if not filter_rule: return True @@ -334,8 +349,17 @@ class TorrentHelper(metaclass=Singleton): # 最少做种人数 min_seeders = filter_rule.get("min_seeders") if min_seeders and torrent_info.seeders < int(min_seeders): - logger.info(f"{torrent_info.title} 做种人数不足 {min_seeders}") - return False + # 最少做种人数生效发布时间(分钟)(在设置发布时间之外的最少做种人数生效) + min_seeders_time = filter_rule.get("min_seeders_time") or 0 + if min_seeders_time: + # 发布时间与当前时间差(分钟) + pubdate_minutes = __get_pubminutes(min_seeders_time) + if pubdate_minutes > min_seeders_time: + logger.info(f"{torrent_info.title} 发布时间大于 {min_seeders_time} 分钟,做种人数不足 {min_seeders}") + return False + else: + logger.info(f"{torrent_info.title} 做种人数不足 {min_seeders}") + return False # 包含 include = filter_rule.get("include")