From 11fedb1ffc0fe6280caf39e5b182740398d4517a Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Sun, 15 Dec 2024 01:27:30 +0800 Subject: [PATCH] fix(download): optimize performance by checking binary content --- app/helper/torrent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helper/torrent.py b/app/helper/torrent.py index 03800430e..a52fccd5c 100644 --- a/app/helper/torrent.py +++ b/app/helper/torrent.py @@ -64,10 +64,10 @@ def download_torrent(self, url: str, if not req.content: return None, None, "", [], "未下载到种子数据" # 解析内容格式 - if req.text and str(req.text).startswith("magnet:"): + if req.content.startswith(b"magnet:"): # 磁力链接 return None, req.text, "", [], f"获取到磁力链接" - elif req.text and "下载种子文件" in req.text: + if "下载种子文件".encode("utf-8") in req.content: # 首次下载提示页面 skip_flag = False try: