mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
refactoring
This commit is contained in:
parent
d59d2c79a1
commit
ccff95f757
@ -54,7 +54,7 @@ class StreamerClient:
|
|||||||
|
|
||||||
async def read_stream(self) -> AsyncGenerator[Tuple[bool, int, int, bytes], None]:
|
async def read_stream(self) -> AsyncGenerator[Tuple[bool, int, int, bytes], None]:
|
||||||
try:
|
try:
|
||||||
async with self.__make_session(infinite=True) as session:
|
async with self.__make_http_session(infinite=True) as session:
|
||||||
async with session.get(
|
async with session.get(
|
||||||
url=self.__make_url("stream"),
|
url=self.__make_url("stream"),
|
||||||
params={"extra_headers": "1"},
|
params={"extra_headers": "1"},
|
||||||
@ -85,7 +85,7 @@ class StreamerClient:
|
|||||||
raise StreamerError("Reached EOF")
|
raise StreamerError("Reached EOF")
|
||||||
|
|
||||||
# async def get_snapshot(self) -> Tuple[bool, bytes]:
|
# async def get_snapshot(self) -> Tuple[bool, bytes]:
|
||||||
# async with self.__make_session(infinite=False) as session:
|
# async with self.__make_http_session(infinite=False) as session:
|
||||||
# async with session.get(self.__make_url("snapshot")) as response:
|
# async with session.get(self.__make_url("snapshot")) as response:
|
||||||
# aiotools.raise_not_200(response)
|
# aiotools.raise_not_200(response)
|
||||||
# return (
|
# return (
|
||||||
@ -93,7 +93,7 @@ class StreamerClient:
|
|||||||
# bytes(await response.read()),
|
# bytes(await response.read()),
|
||||||
# )
|
# )
|
||||||
|
|
||||||
def __make_session(self, infinite: bool) -> aiohttp.ClientSession:
|
def __make_http_session(self, infinite: bool) -> aiohttp.ClientSession:
|
||||||
kwargs: Dict = {"headers": {"User-Agent": self.__user_agent}}
|
kwargs: Dict = {"headers": {"User-Agent": self.__user_agent}}
|
||||||
if infinite:
|
if infinite:
|
||||||
kwargs["timeout"] = aiohttp.ClientTimeout(
|
kwargs["timeout"] = aiohttp.ClientTimeout(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user