mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
backport: 适配馒头API变动
This commit is contained in:
+10
-16
@@ -110,30 +110,24 @@ 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,
|
||||||
}
|
}
|
||||||
res = RequestUtils(
|
res = RequestUtils(
|
||||||
headers=headers,
|
headers=headers,
|
||||||
proxies=settings.PROXY if site.proxy else None,
|
proxies=settings.PROXY if site.proxy else None,
|
||||||
timeout=site.timeout or 15
|
timeout=site.timeout or 15
|
||||||
).post_res(url=url)
|
).post_res(url=url)
|
||||||
if res and res.status_code == 200:
|
if res is None:
|
||||||
user_info = res.json()
|
return False, "无法打开网站!"
|
||||||
if user_info and user_info.get("data"):
|
if res.status_code == 200:
|
||||||
# 更新最后访问时间
|
user_info = res.json() or {}
|
||||||
res = RequestUtils(headers=headers,
|
if user_info.get("data"):
|
||||||
timeout=site.timeout or 15,
|
return True, "连接成功"
|
||||||
proxies=settings.PROXY if site.proxy else None,
|
return False, user_info.get("message", "鉴权已过期或无效")
|
||||||
referer=f"{site.url}index"
|
else:
|
||||||
).post_res(url=f"https://api.{domain}/api/member/updateLastBrowse")
|
return False, f"错误:{res.status_code} {res.reason}"
|
||||||
if res:
|
|
||||||
return True, "连接成功"
|
|
||||||
else:
|
|
||||||
return True, f"连接成功,但更新状态失败"
|
|
||||||
return False, "鉴权已过期或无效"
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __yema_test(site: Site) -> Tuple[bool, str]:
|
def __yema_test(site: Site) -> Tuple[bool, str]:
|
||||||
|
|||||||
@@ -193,7 +193,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
|
||||||
|
|||||||
Reference in New Issue
Block a user