Skip to content

Commit

Permalink
Merge pull request #147 from Starry-OvO/develop
Browse files Browse the repository at this point in the history
Update 3.7.3
  • Loading branch information
lumina37 authored Oct 23, 2023
2 parents 2118b9b + 80e7ea7 commit db7a88a
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 17 deletions.
2 changes: 1 addition & 1 deletion aiotieba/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.7.2"
__version__ = "3.7.3"
6 changes: 6 additions & 0 deletions aiotieba/api/get_comments/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion aiotieba/api/get_images/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from ._api import null_ret_factory, parse_body, request
from ._api import null_ret_factory, parse_body, request, request_bytes
9 changes: 7 additions & 2 deletions aiotieba/api/get_images/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 9 additions & 0 deletions aiotieba/api/get_posts/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions aiotieba/api/get_threads/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions aiotieba/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
"""
Expand Down
2 changes: 1 addition & 1 deletion aiotieba/const.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 0 additions & 8 deletions tests/test_get_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit db7a88a

Please sign in to comment.