mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
Merge pull request #4971 from cddjr/fix_glitch
This commit is contained in:
@@ -20,7 +20,7 @@ async def search_latest(_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
|||||||
"""
|
"""
|
||||||
查询搜索结果
|
查询搜索结果
|
||||||
"""
|
"""
|
||||||
torrents = await SearchChain().async_last_search_results()
|
torrents = await SearchChain().async_last_search_results() or []
|
||||||
return [torrent.to_dict() for torrent in torrents]
|
return [torrent.to_dict() for torrent in torrents]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -86,13 +86,13 @@ class SearchChain(ChainBase):
|
|||||||
self.save_cache(contexts, self.__result_temp_file)
|
self.save_cache(contexts, self.__result_temp_file)
|
||||||
return contexts
|
return contexts
|
||||||
|
|
||||||
def last_search_results(self) -> List[Context]:
|
def last_search_results(self) -> Optional[List[Context]]:
|
||||||
"""
|
"""
|
||||||
获取上次搜索结果
|
获取上次搜索结果
|
||||||
"""
|
"""
|
||||||
return self.load_cache(self.__result_temp_file)
|
return self.load_cache(self.__result_temp_file)
|
||||||
|
|
||||||
async def async_last_search_results(self) -> List[Context]:
|
async def async_last_search_results(self) -> Optional[List[Context]]:
|
||||||
"""
|
"""
|
||||||
异步获取上次搜索结果
|
异步获取上次搜索结果
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
|
|||||||
"refresh_time": int(time.time()),
|
"refresh_time": int(time.time()),
|
||||||
**tokens
|
**tokens
|
||||||
})
|
})
|
||||||
|
else:
|
||||||
|
return None
|
||||||
access_token = tokens.get("access_token")
|
access_token = tokens.get("access_token")
|
||||||
if access_token:
|
if access_token:
|
||||||
self.session.headers.update({"Authorization": f"Bearer {access_token}"})
|
self.session.headers.update({"Authorization": f"Bearer {access_token}"})
|
||||||
@@ -211,6 +213,8 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
|
|||||||
|
|
||||||
# 错误日志标志
|
# 错误日志标志
|
||||||
no_error_log = kwargs.pop("no_error_log", False)
|
no_error_log = kwargs.pop("no_error_log", False)
|
||||||
|
# 重试次数
|
||||||
|
retry_times = kwargs.pop("retry_limit", 5)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = self.session.request(
|
resp = self.session.request(
|
||||||
@@ -225,6 +229,8 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
|
|||||||
logger.warn(f"【115】{method} 请求 {endpoint} 失败!")
|
logger.warn(f"【115】{method} 请求 {endpoint} 失败!")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
kwargs["retry_limit"] = retry_times
|
||||||
|
|
||||||
# 处理速率限制
|
# 处理速率限制
|
||||||
if resp.status_code == 429:
|
if resp.status_code == 429:
|
||||||
reset_time = 5 + int(resp.headers.get("X-RateLimit-Reset", 60))
|
reset_time = 5 + int(resp.headers.get("X-RateLimit-Reset", 60))
|
||||||
@@ -243,7 +249,6 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
|
|||||||
error_msg = ret_data.get("message")
|
error_msg = ret_data.get("message")
|
||||||
if not no_error_log:
|
if not no_error_log:
|
||||||
logger.warn(f"【115】{method} 请求 {endpoint} 出错:{error_msg}")
|
logger.warn(f"【115】{method} 请求 {endpoint} 出错:{error_msg}")
|
||||||
retry_times = kwargs.get("retry_limit", 5)
|
|
||||||
if "已达到当前访问上限" in error_msg:
|
if "已达到当前访问上限" in error_msg:
|
||||||
if retry_times <= 0:
|
if retry_times <= 0:
|
||||||
logger.error(f"【115】{method} 请求 {endpoint} 达到访问上限,重试次数用尽!")
|
logger.error(f"【115】{method} 请求 {endpoint} 达到访问上限,重试次数用尽!")
|
||||||
|
|||||||
@@ -747,6 +747,9 @@ class TmdbApi:
|
|||||||
logger.info("正在从TheDbMovie网站查询:%s ..." % name)
|
logger.info("正在从TheDbMovie网站查询:%s ..." % name)
|
||||||
tmdb_url = self._build_tmdb_search_url(name)
|
tmdb_url = self._build_tmdb_search_url(name)
|
||||||
res = RequestUtils(timeout=5, ua=settings.NORMAL_USER_AGENT, proxies=settings.PROXY).get_res(url=tmdb_url)
|
res = RequestUtils(timeout=5, ua=settings.NORMAL_USER_AGENT, proxies=settings.PROXY).get_res(url=tmdb_url)
|
||||||
|
if res is None:
|
||||||
|
logger.error("无法连接TheDbMovie")
|
||||||
|
return None
|
||||||
|
|
||||||
# 响应验证
|
# 响应验证
|
||||||
response_result = self._validate_response(res)
|
response_result = self._validate_response(res)
|
||||||
@@ -1857,6 +1860,9 @@ class TmdbApi:
|
|||||||
tmdb_url = self._build_tmdb_search_url(name)
|
tmdb_url = self._build_tmdb_search_url(name)
|
||||||
res = await AsyncRequestUtils(timeout=5, ua=settings.NORMAL_USER_AGENT, proxies=settings.PROXY).get_res(
|
res = await AsyncRequestUtils(timeout=5, ua=settings.NORMAL_USER_AGENT, proxies=settings.PROXY).get_res(
|
||||||
url=tmdb_url)
|
url=tmdb_url)
|
||||||
|
if res is None:
|
||||||
|
logger.error("无法连接TheDbMovie")
|
||||||
|
return None
|
||||||
|
|
||||||
# 响应验证
|
# 响应验证
|
||||||
response_result = self._validate_response(res)
|
response_result = self._validate_response(res)
|
||||||
|
|||||||
Reference in New Issue
Block a user