From 6541458326bd03baf57e809f625367e433c0a48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=AF=E5=A4=A7=E4=BE=A0?= Date: Thu, 10 Apr 2025 14:17:58 +0800 Subject: [PATCH] =?UTF-8?q?backport:=20=E9=80=82=E9=85=8D=E9=A6=92?= =?UTF-8?q?=E5=A4=B4API=E5=8F=98=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/site.py | 26 ++++++++++---------------- app/modules/indexer/mtorrent.py | 1 - 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/app/chain/site.py b/app/chain/site.py index 146a51d2..cbcdee39 100644 --- a/app/chain/site.py +++ b/app/chain/site.py @@ -110,30 +110,24 @@ class SiteChain(ChainBase): domain = StringUtils.get_url_domain(site.url) url = f"https://api.{domain}/api/member/profile" headers = { - "Content-Type": "application/json", "User-Agent": user_agent, "Accept": "application/json, text/plain, */*", - "Authorization": site.token + "x-api-key": site.apikey, } res = RequestUtils( headers=headers, proxies=settings.PROXY if site.proxy else None, timeout=site.timeout or 15 ).post_res(url=url) - if res and res.status_code == 200: - user_info = res.json() - if user_info and user_info.get("data"): - # 更新最后访问时间 - res = RequestUtils(headers=headers, - timeout=site.timeout or 15, - proxies=settings.PROXY if site.proxy else None, - referer=f"{site.url}index" - ).post_res(url=f"https://api.{domain}/api/member/updateLastBrowse") - if res: - return True, "连接成功" - else: - return True, f"连接成功,但更新状态失败" - return False, "鉴权已过期或无效" + if res is None: + return False, "无法打开网站!" + if res.status_code == 200: + user_info = res.json() or {} + if user_info.get("data"): + return True, "连接成功" + return False, user_info.get("message", "鉴权已过期或无效") + else: + return False, f"错误:{res.status_code} {res.reason}" @staticmethod def __yema_test(site: Site) -> Tuple[bool, str]: diff --git a/app/modules/indexer/mtorrent.py b/app/modules/indexer/mtorrent.py index 62346c69..54df030c 100644 --- a/app/modules/indexer/mtorrent.py +++ b/app/modules/indexer/mtorrent.py @@ -193,7 +193,6 @@ class MTorrentSpider: 'id': torrent_id }, 'header': { - 'Content-Type': 'application/json', 'User-Agent': f'{self._ua}', 'Accept': 'application/json, text/plain, */*', 'x-api-key': self._apikey