mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
fix httpx
This commit is contained in:
@@ -12,7 +12,6 @@ import requests
|
||||
|
||||
from app.core.cache import cached
|
||||
from app.core.config import settings
|
||||
from app.utils.asyncio import AsyncUtils
|
||||
from app.utils.http import RequestUtils, AsyncRequestUtils
|
||||
from app.utils.singleton import WeakSingleton
|
||||
|
||||
@@ -156,7 +155,6 @@ class DoubanApi(metaclass=WeakSingleton):
|
||||
|
||||
def __init__(self):
|
||||
self._session = requests.Session()
|
||||
self._client = httpx.AsyncClient()
|
||||
|
||||
@classmethod
|
||||
def __sign(cls, url: str, ts: str, method='GET') -> str:
|
||||
@@ -251,8 +249,7 @@ class DoubanApi(metaclass=WeakSingleton):
|
||||
"""
|
||||
req_url, params = self._prepare_get_request(url, **kwargs)
|
||||
resp = await AsyncRequestUtils(
|
||||
ua=choice(self._user_agents),
|
||||
client=self._client
|
||||
ua=choice(self._user_agents)
|
||||
).get_res(url=req_url, params=params)
|
||||
return self._handle_response(resp)
|
||||
|
||||
@@ -297,8 +294,7 @@ class DoubanApi(metaclass=WeakSingleton):
|
||||
"""
|
||||
req_url, params = self._prepare_post_request(url, **kwargs)
|
||||
resp = await AsyncRequestUtils(
|
||||
ua=settings.NORMAL_USER_AGENT,
|
||||
client=self._client
|
||||
ua=settings.NORMAL_USER_AGENT
|
||||
).post_res(url=req_url, data=params)
|
||||
return self._handle_response(resp)
|
||||
|
||||
@@ -876,5 +872,3 @@ class DoubanApi(metaclass=WeakSingleton):
|
||||
def close(self):
|
||||
if self._session:
|
||||
self._session.close()
|
||||
if self._client:
|
||||
AsyncUtils.run_async(self._client.aclose())
|
||||
|
||||
Reference in New Issue
Block a user