fix: 黄豆按站点方式保持登录并自动切换播放线路
This commit is contained in:
+11
-1
@@ -127,7 +127,17 @@ class HttpClient:
|
||||
options["content"] = content
|
||||
if timeout is not None:
|
||||
options["timeout"] = timeout
|
||||
return self._client_locked().request(method, url, **options)
|
||||
last_error: Exception | None = None
|
||||
for attempt in range(3):
|
||||
try:
|
||||
return self._client_locked().request(method, url, **options)
|
||||
except (httpx.HTTPError, TimeoutError, OSError) as exc:
|
||||
last_error = exc
|
||||
with self._lock:
|
||||
self._close_locked()
|
||||
if attempt < 2:
|
||||
time.sleep(0.4 * (attempt + 1))
|
||||
raise RuntimeError(f"请求失败: {last_error}")
|
||||
|
||||
def get_bytes(self, url: str, headers: dict | None = None) -> tuple[bytes, str]:
|
||||
hdrs = {"User-Agent": "RaptDrama"}
|
||||
|
||||
Reference in New Issue
Block a user