diff --git a/aiotieba/__version__.py b/aiotieba/__version__.py index 3bdbbae2..221485ae 100644 --- a/aiotieba/__version__.py +++ b/aiotieba/__version__.py @@ -1 +1 @@ -__version__ = "3.7.2" +__version__ = "3.7.3" diff --git a/aiotieba/api/get_comments/_classdef.py b/aiotieba/api/get_comments/_classdef.py index 5cdce5d2..e48caf5a 100644 --- a/aiotieba/api/get_comments/_classdef.py +++ b/aiotieba/api/get_comments/_classdef.py @@ -84,6 +84,9 @@ def _frags(): self._tiebapluses.append(frag) self._texts.append(frag) yield frag + # outdated tiebaplus + elif _type == 34: + continue else: from ...logging import get_logger as LOG @@ -1270,6 +1273,9 @@ def _frags(): self._tiebapluses.append(frag) self._texts.append(frag) yield frag + # outdated tiebaplus + elif _type == 34: + continue else: from ...logging import get_logger as LOG diff --git a/aiotieba/api/get_images/__init__.py b/aiotieba/api/get_images/__init__.py index 23ca3a44..8da709c2 100644 --- a/aiotieba/api/get_images/__init__.py +++ b/aiotieba/api/get_images/__init__.py @@ -1 +1 @@ -from ._api import null_ret_factory, parse_body, request +from ._api import null_ret_factory, parse_body, request, request_bytes diff --git a/aiotieba/api/get_images/_api.py b/aiotieba/api/get_images/_api.py index a2978522..77cd35a9 100644 --- a/aiotieba/api/get_images/_api.py +++ b/aiotieba/api/get_images/_api.py @@ -35,10 +35,15 @@ def parse_body(body: bytes) -> "np.ndarray": return image -async def request(http_core: HttpCore, url: yarl.URL) -> "np.ndarray": +async def request_bytes(http_core: HttpCore, url: yarl.URL) -> bytes: request = http_core.pack_web_get_request(url, []) __log__ = "url={url}" # noqa: F841 - body = await http_core.net_core.send_request(request, read_bufsize=512 * 1024, headers_checker=headers_checker) + body = await http_core.net_core.send_request(request, read_bufsize=256 * 1024, headers_checker=headers_checker) + return body + + +async def request(http_core: HttpCore, url: yarl.URL) -> "np.ndarray": + body = await request_bytes(http_core, url) return parse_body(body) diff --git a/aiotieba/api/get_posts/_classdef.py b/aiotieba/api/get_posts/_classdef.py index 7553a434..d7c2034b 100644 --- a/aiotieba/api/get_posts/_classdef.py +++ b/aiotieba/api/get_posts/_classdef.py @@ -328,6 +328,9 @@ def _frags(): self._tiebapluses.append(frag) self._texts.append(frag) yield frag + # outdated tiebaplus + elif _type == 34: + continue else: from ...logging import get_logger as LOG @@ -499,6 +502,9 @@ def _frags(): self._tiebapluses.append(frag) self._texts.append(frag) yield frag + # outdated tiebaplus + elif _type == 34: + continue else: from ...logging import get_logger as LOG @@ -1644,6 +1650,9 @@ def _frags(): self._tiebapluses.append(frag) self._texts.append(frag) yield frag + # outdated tiebaplus + elif _type == 34: + continue else: from ...logging import get_logger as LOG diff --git a/aiotieba/api/get_threads/_classdef.py b/aiotieba/api/get_threads/_classdef.py index a0afc7cd..9e14676b 100644 --- a/aiotieba/api/get_threads/_classdef.py +++ b/aiotieba/api/get_threads/_classdef.py @@ -218,6 +218,9 @@ def _frags(): self._tiebapluses.append(frag) self._texts.append(frag) yield frag + # outdated tiebaplus + elif _type == 34: + continue else: from ...logging import get_logger as LOG @@ -870,6 +873,9 @@ def _frags(): self._tiebapluses.append(frag) self._texts.append(frag) yield frag + # outdated tiebaplus + elif _type == 34: + continue else: from ...logging import get_logger as LOG diff --git a/aiotieba/client.py b/aiotieba/client.py index 3001ca59..0270a977 100644 --- a/aiotieba/client.py +++ b/aiotieba/client.py @@ -924,6 +924,20 @@ async def get_ats(self, pn: int = 1) -> get_ats.Ats: return await get_ats.request(self._http_core, pn) + @handle_exception(bytes) + async def get_image_bytes(self, img_url: str) -> bytes: + """ + 从链接获取静态图像的原始字节流 + + Args: + img_url (str): 图像链接 + + Returns: + bytes: 未解码的原始字节流 + """ + + return await get_images.request_bytes(self._http_core, yarl.URL(img_url)) + @handle_exception(get_images.null_ret_factory) async def get_image(self, img_url: str) -> "np.ndarray": """ diff --git a/aiotieba/const.py b/aiotieba/const.py index 9b8ad1d7..c1d236dc 100644 --- a/aiotieba/const.py +++ b/aiotieba/const.py @@ -1,4 +1,4 @@ -MAIN_VERSION = "12.46.3.0" +MAIN_VERSION = "12.49.1.0" POST_VERSION = "12.35.1.0" APP_SECURE_SCHEME = "https" diff --git a/pyproject.toml b/pyproject.toml index 64821b95..ad9d9e2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,10 +54,10 @@ speedup = [ "pysimdjson<6,>=3.1.1;python_version=='3.9'", "pysimdjson<6,>=4.0.3;python_version=='3.10'", "pysimdjson<6,>=5.0.1;python_version>='3.11'", - "uvloop<0.18,>=0.14.0;python_version=='3.8' and sys_platform!='win32'", - "uvloop<0.18,>=0.15.0;python_version=='3.9' and sys_platform!='win32'", - "uvloop<0.18,>=0.16.0;python_version=='3.10' and sys_platform!='win32'", - "uvloop<0.18,>=0.17.0;python_version>='3.11' and sys_platform!='win32'", + "uvloop<0.20,>=0.14.0;python_version=='3.8' and sys_platform!='win32'", + "uvloop<0.20,>=0.15.0;python_version=='3.9' and sys_platform!='win32'", + "uvloop<0.20,>=0.16.0;python_version=='3.10' and sys_platform!='win32'", + "uvloop<0.20,>=0.17.0;python_version>='3.11' and sys_platform!='win32'", ] [tool.setuptools.packages.find] diff --git a/tests/test_get_comments.py b/tests/test_get_comments.py index a8e20090..19604b93 100644 --- a/tests/test_get_comments.py +++ b/tests/test_get_comments.py @@ -89,14 +89,6 @@ async def test_Comments(client: tb.Client): assert frag.desc != '' assert frag.id == 'image_emoticon3' - # FragTiebaplus - frag = post.contents.tiebapluses[0] - assert frag.text != '' - assert frag.url != '' - frag = post.contents.tiebapluses[1] - assert frag.text != '' - assert frag.url != '' - ##### Comment ##### comment = comments[0]