修复馒头请求参数错误的问题

This commit is contained in:
景大侠
2025-04-07 21:04:21 +08:00
parent 0afc38f6b8
commit 7d8cda0457
2 changed files with 2 additions and 24 deletions

View File

@@ -1,7 +1,6 @@
import base64 import base64
import re import re
from datetime import datetime from datetime import datetime
from time import time
from typing import Optional, Tuple, Union, Dict from typing import Optional, Tuple, Union, Dict
from urllib.parse import urljoin from urllib.parse import urljoin
@@ -178,12 +177,9 @@ class SiteChain(ChainBase):
domain = StringUtils.get_url_domain(site.url) domain = StringUtils.get_url_domain(site.url)
url = f"https://api.{domain}/api/member/profile" url = f"https://api.{domain}/api/member/profile"
headers = { headers = {
"Content-Type": "application/json",
"User-Agent": user_agent, "User-Agent": user_agent,
"Accept": "application/json, text/plain, */*", "Accept": "application/json, text/plain, */*",
"Authorization": site.token,
"x-api-key": site.apikey, "x-api-key": site.apikey,
"ts": str(int(time()))
} }
res = RequestUtils( res = RequestUtils(
headers=headers, headers=headers,
@@ -193,27 +189,10 @@ class SiteChain(ChainBase):
if res is None: if res is None:
return False, "无法打开网站!" return False, "无法打开网站!"
if res.status_code == 200: if res.status_code == 200:
state = False
message = "鉴权已过期或无效"
user_info = res.json() or {} user_info = res.json() or {}
if user_info.get("data"): if user_info.get("data"):
# 更新最后访问时间 return True, "连接成功"
del headers["x-api-key"] return False, user_info.get("message", "鉴权已过期或无效")
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")
state = True
message = "连接成功,但更新状态失败"
if res and res.status_code == 200:
update_info = res.json() or {}
if "code" in update_info and int(update_info["code"]) == 0:
message = "连接成功"
elif user_info.get("message"):
# 使用馒头的错误提示
message = user_info.get("message")
return state, message
else: else:
return False, f"错误:{res.status_code} {res.reason}" return False, f"错误:{res.status_code} {res.reason}"

View File

@@ -191,7 +191,6 @@ class MTorrentSpider:
'id': torrent_id 'id': torrent_id
}, },
'header': { 'header': {
'Content-Type': 'application/json',
'User-Agent': f'{self._ua}', 'User-Agent': f'{self._ua}',
'Accept': 'application/json, text/plain, */*', 'Accept': 'application/json, text/plain, */*',
'x-api-key': self._apikey 'x-api-key': self._apikey