mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 16:36:53 +08:00
fix res.text
This commit is contained in:
+6
-4
@@ -356,9 +356,10 @@ class SiteChain(ChainBase):
|
|||||||
ua=settings.USER_AGENT
|
ua=settings.USER_AGENT
|
||||||
).get_res(url=domain_url)
|
).get_res(url=domain_url)
|
||||||
if res and res.status_code in [200, 500, 403]:
|
if res and res.status_code in [200, 500, 403]:
|
||||||
if not indexer.get("public") and not SiteUtils.is_logged_in(res.text):
|
content = res.text
|
||||||
|
if not indexer.get("public") and not SiteUtils.is_logged_in(content):
|
||||||
_fail_count += 1
|
_fail_count += 1
|
||||||
if under_challenge(res.text):
|
if under_challenge(content):
|
||||||
logger.warn(f"站点 {indexer.get('name')} 被Cloudflare防护,无法登录,无法添加站点")
|
logger.warn(f"站点 {indexer.get('name')} 被Cloudflare防护,无法登录,无法添加站点")
|
||||||
continue
|
continue
|
||||||
logger.warn(
|
logger.warn(
|
||||||
@@ -576,8 +577,9 @@ class SiteChain(ChainBase):
|
|||||||
).get_res(url=site_url)
|
).get_res(url=site_url)
|
||||||
# 判断登录状态
|
# 判断登录状态
|
||||||
if res and res.status_code in [200, 500, 403]:
|
if res and res.status_code in [200, 500, 403]:
|
||||||
if not public and not SiteUtils.is_logged_in(res.text):
|
content = res.text
|
||||||
if under_challenge(res.text):
|
if not public and not SiteUtils.is_logged_in(content):
|
||||||
|
if under_challenge(content):
|
||||||
msg = "站点被Cloudflare防护,请打开站点浏览器仿真"
|
msg = "站点被Cloudflare防护,请打开站点浏览器仿真"
|
||||||
elif res.status_code == 200:
|
elif res.status_code == 200:
|
||||||
msg = "Cookie已失效"
|
msg = "Cookie已失效"
|
||||||
|
|||||||
+11
-9
@@ -1,15 +1,16 @@
|
|||||||
import sys
|
import importlib
|
||||||
import json
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
import traceback
|
|
||||||
import site
|
import site
|
||||||
import importlib
|
import sys
|
||||||
|
import traceback
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Set
|
from typing import Dict, List, Optional, Tuple, Set
|
||||||
|
|
||||||
from packaging.specifiers import SpecifierSet, InvalidSpecifier
|
from packaging.specifiers import SpecifierSet, InvalidSpecifier
|
||||||
from packaging.version import Version, InvalidVersion
|
from packaging.version import Version, InvalidVersion
|
||||||
from pkg_resources import Requirement, working_set
|
from pkg_resources import Requirement, working_set
|
||||||
|
from requests import Response
|
||||||
|
|
||||||
from app.core.cache import cached
|
from app.core.cache import cached
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
@@ -85,11 +86,12 @@ class PluginHelper(metaclass=Singleton):
|
|||||||
if res is None:
|
if res is None:
|
||||||
return None
|
return None
|
||||||
if res:
|
if res:
|
||||||
|
content = res.text
|
||||||
try:
|
try:
|
||||||
return json.loads(res.text)
|
return json.loads(content)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
if "404: Not Found" not in res.text:
|
if "404: Not Found" not in content:
|
||||||
logger.warn(f"插件包数据解析失败:{res.text}")
|
logger.warn(f"插件包数据解析失败:{content}")
|
||||||
return None
|
return None
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -318,7 +320,7 @@ class PluginHelper(metaclass=Singleton):
|
|||||||
else:
|
else:
|
||||||
return None, "插件在仓库中不存在或返回数据格式不正确"
|
return None, "插件在仓库中不存在或返回数据格式不正确"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"插件数据解析失败:{res.text},{e}")
|
logger.error(f"插件数据解析失败:{e}")
|
||||||
return None, "插件数据解析失败"
|
return None, "插件数据解析失败"
|
||||||
|
|
||||||
def __download_files(self, pid: str, file_list: List[dict], user_repo: str,
|
def __download_files(self, pid: str, file_list: List[dict], user_repo: str,
|
||||||
@@ -521,7 +523,7 @@ class PluginHelper(metaclass=Singleton):
|
|||||||
def __request_with_fallback(url: str,
|
def __request_with_fallback(url: str,
|
||||||
headers: Optional[dict] = None,
|
headers: Optional[dict] = None,
|
||||||
timeout: Optional[int] = 60,
|
timeout: Optional[int] = 60,
|
||||||
is_api: bool = False) -> Optional[Any]:
|
is_api: bool = False) -> Optional[Response]:
|
||||||
"""
|
"""
|
||||||
使用自动降级策略,请求资源,优先级依次为镜像站、代理、直连
|
使用自动降级策略,请求资源,优先级依次为镜像站、代理、直连
|
||||||
:param url: 目标URL
|
:param url: 目标URL
|
||||||
|
|||||||
Reference in New Issue
Block a user