mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-13 17:29:46 +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]
|
||||
|
||||
|
||||
|
||||
@@ -86,13 +86,13 @@ class SearchChain(ChainBase):
|
||||
self.save_cache(contexts, self.__result_temp_file)
|
||||
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)
|
||||
|
||||
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()),
|
||||
**tokens
|
||||
})
|
||||
else:
|
||||
return None
|
||||
access_token = tokens.get("access_token")
|
||||
if 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)
|
||||
# 重试次数
|
||||
retry_times = kwargs.pop("retry_limit", 5)
|
||||
|
||||
try:
|
||||
resp = self.session.request(
|
||||
@@ -225,6 +229,8 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
|
||||
logger.warn(f"【115】{method} 请求 {endpoint} 失败!")
|
||||
return None
|
||||
|
||||
kwargs["retry_limit"] = retry_times
|
||||
|
||||
# 处理速率限制
|
||||
if resp.status_code == 429:
|
||||
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")
|
||||
if not no_error_log:
|
||||
logger.warn(f"【115】{method} 请求 {endpoint} 出错:{error_msg}")
|
||||
retry_times = kwargs.get("retry_limit", 5)
|
||||
if "已达到当前访问上限" in error_msg:
|
||||
if retry_times <= 0:
|
||||
logger.error(f"【115】{method} 请求 {endpoint} 达到访问上限,重试次数用尽!")
|
||||
|
||||
@@ -747,6 +747,9 @@ class TmdbApi:
|
||||
logger.info("正在从TheDbMovie网站查询:%s ..." % 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)
|
||||
if res is None:
|
||||
logger.error("无法连接TheDbMovie")
|
||||
return None
|
||||
|
||||
# 响应验证
|
||||
response_result = self._validate_response(res)
|
||||
@@ -1857,6 +1860,9 @@ class TmdbApi:
|
||||
tmdb_url = self._build_tmdb_search_url(name)
|
||||
res = await AsyncRequestUtils(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)
|
||||
|
||||
Reference in New Issue
Block a user