From 52e2df266c9c7257c64504355f53f63b1e4ff48e Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Thu, 11 Apr 2024 15:16:40 +0800 Subject: [PATCH 01/10] fix: unused import --- aiotieba/api/get_bawu_postlogs/_classdef.py | 1 - pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/aiotieba/api/get_bawu_postlogs/_classdef.py b/aiotieba/api/get_bawu_postlogs/_classdef.py index e9155362..a7b425b3 100644 --- a/aiotieba/api/get_bawu_postlogs/_classdef.py +++ b/aiotieba/api/get_bawu_postlogs/_classdef.py @@ -1,6 +1,5 @@ import dataclasses as dcs from datetime import datetime -from functools import cached_property from typing import List import bs4 diff --git a/pyproject.toml b/pyproject.toml index 867541b7..748dbcb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "aiotieba" -version = "4.4.3" +version = "4.4.4a0" description = "Asynchronous I/O Client for Baidu Tieba" authors = [{ name = "Starry-OvO", email = "starry.qvq@gmail.com" }] urls = { Repository = "https://github.com/Starry-OvO/aiotieba/", Documentation = "https://aiotieba.cc/" } From deaf33aaa7cdbd90d598325d55c0794c58a08598 Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Mon, 15 Apr 2024 11:32:29 +0800 Subject: [PATCH 02/10] chore: bump client version to 12.59.0.2 --- aiotieba/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiotieba/const.py b/aiotieba/const.py index ad644a1e..7977bcd8 100644 --- a/aiotieba/const.py +++ b/aiotieba/const.py @@ -1,4 +1,4 @@ -MAIN_VERSION = "12.58.2.1" +MAIN_VERSION = "12.59.0.2" POST_VERSION = "12.35.1.0" APP_SECURE_SCHEME = "https" From 59a73fc35d819bee859c747f220a895a6c6895b1 Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Wed, 17 Apr 2024 09:04:23 +0800 Subject: [PATCH 03/10] chore: enable more CI logs --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f5fd4c03..23ca1dab 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -42,7 +42,7 @@ jobs: - name: Pin Py${{ matrix.python-version }} run: | rye pin ${{ matrix.python-version }} - rye sync --features=speedup -q + rye sync --features=speedup - name: Run tests env: From a698e13289e2b6c44736b6562333b034362da9e5 Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Wed, 17 Apr 2024 09:04:53 +0800 Subject: [PATCH 04/10] chore: add note for some api that require STOKEN --- aiotieba/client.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/aiotieba/client.py b/aiotieba/client.py index 4291fda9..5c552fe0 100644 --- a/aiotieba/client.py +++ b/aiotieba/client.py @@ -1269,6 +1269,9 @@ async def get_member_users(self, fname_or_fid: Union[str, int], /, pn: int = 1) Returns: MemberUsers: 最新关注用户列表 + + Note: + 本接口需要STOKEN """ fname = fname_or_fid if isinstance(fname_or_fid, str) else await self.__get_fname(fname_or_fid) @@ -1367,6 +1370,9 @@ async def get_bawu_userlogs( Returns: Userlogs: 吧务用户管理日志表 + + Note: + 本接口需要STOKEN """ fname = fname_or_fid if isinstance(fname_or_fid, str) else await self.__get_fname(fname_or_fid) @@ -1402,6 +1408,9 @@ async def get_bawu_postlogs( Returns: Postlogs: 吧务帖子管理日志表 + + Note: + 本接口需要STOKEN """ fname = fname_or_fid if isinstance(fname_or_fid, str) else await self.__get_fname(fname_or_fid) @@ -1444,6 +1453,9 @@ async def get_bawu_blacklist( Returns: BlacklistUsers: 吧务黑名单列表 + + Note: + 本接口需要STOKEN """ fname = fname_or_fid if isinstance(fname_or_fid, str) else await self.__get_fname(fname_or_fid) From ee729d3235f233ae3b1c951cbc99648a4623218e Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Wed, 17 Apr 2024 09:11:27 +0800 Subject: [PATCH 05/10] feat: supporting frag type 40 --- aiotieba/api/get_posts/_classdef.py | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aiotieba/api/get_posts/_classdef.py b/aiotieba/api/get_posts/_classdef.py index adca8ea5..f55a4ad1 100644 --- a/aiotieba/api/get_posts/_classdef.py +++ b/aiotieba/api/get_posts/_classdef.py @@ -149,8 +149,8 @@ def from_tbdata(data_proto: TypeMessage) -> "Contents_p": def _frags(): for proto in content_protos: _type = proto.type - # 0纯文本 9电话号 18话题 27百科词条 - if _type in [0, 9, 18, 27]: + # 0纯文本 9电话号 18话题 27百科词条 40梗百科 + if _type in [0, 9, 18, 27, 40]: frag = FragText_p.from_tbdata(proto) texts.append(frag) yield frag diff --git a/pyproject.toml b/pyproject.toml index 748dbcb2..d7523c8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "aiotieba" -version = "4.4.4a0" +version = "4.4.4a1" description = "Asynchronous I/O Client for Baidu Tieba" authors = [{ name = "Starry-OvO", email = "starry.qvq@gmail.com" }] urls = { Repository = "https://github.com/Starry-OvO/aiotieba/", Documentation = "https://aiotieba.cc/" } From 176d7a6f357e1b02598a5a75b88192d202abdddc Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Wed, 17 Apr 2024 15:26:40 +0800 Subject: [PATCH 06/10] fix: `sign_forum` ret error --- aiotieba/api/sign_forum/_api.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aiotieba/api/sign_forum/_api.py b/aiotieba/api/sign_forum/_api.py index a69adeaf..c2c2c66a 100644 --- a/aiotieba/api/sign_forum/_api.py +++ b/aiotieba/api/sign_forum/_api.py @@ -29,4 +29,4 @@ async def request(http_core: HttpCore, fname: str) -> BoolResponse: body = await http_core.net_core.send_request(request, read_bufsize=2 * 1024) parse_body(body) - return BoolResponse + return BoolResponse() diff --git a/pyproject.toml b/pyproject.toml index d7523c8f..54b2505e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "aiotieba" -version = "4.4.4a1" +version = "4.4.4a2" description = "Asynchronous I/O Client for Baidu Tieba" authors = [{ name = "Starry-OvO", email = "starry.qvq@gmail.com" }] urls = { Repository = "https://github.com/Starry-OvO/aiotieba/", Documentation = "https://aiotieba.cc/" } From f51e1bd1b95ed64c9de7aad20db08bed80c327f7 Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Fri, 19 Apr 2024 11:15:08 +0800 Subject: [PATCH 07/10] fix: `get_bawu_logs` requires url quoting for 2 times --- aiotieba/api/get_bawu_postlogs/_api.py | 2 ++ aiotieba/api/get_bawu_userlogs/_api.py | 2 ++ aiotieba/const.py | 2 +- pyproject.toml | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/aiotieba/api/get_bawu_postlogs/_api.py b/aiotieba/api/get_bawu_postlogs/_api.py index dcf7cec4..f20cf797 100644 --- a/aiotieba/api/get_bawu_postlogs/_api.py +++ b/aiotieba/api/get_bawu_postlogs/_api.py @@ -1,5 +1,6 @@ import datetime from typing import Optional +from urllib.parse import quote import bs4 import yarl @@ -37,6 +38,7 @@ async def request( params.append(('op_type', op_type)) if search_value: + search_value = quote(search_value) extend_params = [ ('svalue', search_value), ('stype', 'post_uname' if search_type == BawuSearchType.USER else 'op_uname'), diff --git a/aiotieba/api/get_bawu_userlogs/_api.py b/aiotieba/api/get_bawu_userlogs/_api.py index f9aed58f..5a85fd1c 100644 --- a/aiotieba/api/get_bawu_userlogs/_api.py +++ b/aiotieba/api/get_bawu_userlogs/_api.py @@ -1,5 +1,6 @@ import datetime from typing import Optional +from urllib.parse import quote import bs4 import yarl @@ -37,6 +38,7 @@ async def request( params.append(('op_type', op_type)) if search_value: + search_value = quote(search_value) extend_params = [ ('svalue', search_value), ('stype', 'post_uname' if search_type == BawuSearchType.USER else 'op_uname'), diff --git a/aiotieba/const.py b/aiotieba/const.py index 7977bcd8..d0b3f2ec 100644 --- a/aiotieba/const.py +++ b/aiotieba/const.py @@ -1,4 +1,4 @@ -MAIN_VERSION = "12.59.0.2" +MAIN_VERSION = "12.59.1.0" POST_VERSION = "12.35.1.0" APP_SECURE_SCHEME = "https" diff --git a/pyproject.toml b/pyproject.toml index 54b2505e..3da09041 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "aiotieba" -version = "4.4.4a2" +version = "4.4.4a3" description = "Asynchronous I/O Client for Baidu Tieba" authors = [{ name = "Starry-OvO", email = "starry.qvq@gmail.com" }] urls = { Repository = "https://github.com/Starry-OvO/aiotieba/", Documentation = "https://aiotieba.cc/" } From c7e7a706a69bdc5b6cc9e09ab6621e017095a357 Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Fri, 19 Apr 2024 19:30:22 +0800 Subject: [PATCH 08/10] chore: compatible with scikit-build-core==0.9.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3da09041..dbf1905d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ speedup = [ ] [build-system] -requires = ["scikit-build-core<0.9,>=0.8"] +requires = ["scikit-build-core<0.10,>=0.8"] build-backend = "scikit_build_core.build" [tool.rye] From 91ec0a64fa65ee1a0b07a35430169c159c9fbc39 Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Fri, 19 Apr 2024 20:04:14 +0800 Subject: [PATCH 09/10] fix: set account may not change the cookies --- aiotieba/client.py | 4 ++-- aiotieba/core/http.py | 11 ++++++++--- aiotieba/core/websocket.py | 5 ++++- pyproject.toml | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/aiotieba/client.py b/aiotieba/client.py index 5c552fe0..9c0a3212 100644 --- a/aiotieba/client.py +++ b/aiotieba/client.py @@ -226,8 +226,8 @@ def account(self) -> Account: @account.setter def account(self, new_account: Account) -> None: - self._http_core.account = new_account - self._ws_core.account = new_account + self._http_core.set_account(new_account) + self._ws_core.set_account(new_account) @handle_exception(BoolResponse) async def init_websocket(self) -> BoolResponse: diff --git a/aiotieba/core/http.py b/aiotieba/core/http.py index b664ae09..bf6dc30d 100644 --- a/aiotieba/core/http.py +++ b/aiotieba/core/http.py @@ -42,7 +42,6 @@ class HttpCore: loop: asyncio.AbstractEventLoop def __init__(self, account: Account, net_core: NetCore, loop: Optional[asyncio.AbstractEventLoop] = None) -> None: - self.account = account self.net_core = net_core self.loop = loop @@ -72,12 +71,18 @@ def __init__(self, account: Account, net_core: NetCore, loop: Optional[asyncio.A hdrs.CONNECTION: "keep-alive", } self.web = HttpContainer(web_headers, aiohttp.CookieJar(loop=loop)) + + self.set_account(account) + + def set_account(self, new_account: Account) -> None: + self.account = new_account + BDUSS_morsel = aiohttp.cookiejar.Morsel() - BDUSS_morsel.set('BDUSS', account.BDUSS, account.BDUSS) + BDUSS_morsel.set('BDUSS', new_account.BDUSS, new_account.BDUSS) BDUSS_morsel['domain'] = "baidu.com" self.web.cookie_jar._cookies[("baidu.com", "/")]['BDUSS'] = BDUSS_morsel STOKEN_morsel = aiohttp.cookiejar.Morsel() - STOKEN_morsel.set('STOKEN', account.STOKEN, account.STOKEN) + STOKEN_morsel.set('STOKEN', new_account.STOKEN, new_account.STOKEN) STOKEN_morsel['domain'] = "tieba.baidu.com" self.web.cookie_jar._cookies[("tieba.baidu.com", "/")]['STOKEN'] = STOKEN_morsel diff --git a/aiotieba/core/websocket.py b/aiotieba/core/websocket.py index b288cef3..76d063a9 100644 --- a/aiotieba/core/websocket.py +++ b/aiotieba/core/websocket.py @@ -277,7 +277,7 @@ class WsCore: loop: asyncio.AbstractEventLoop def __init__(self, account: Account, net_core: NetCore, loop: asyncio.AbstractEventLoop) -> None: - self.account = account + self.set_account(account) self.net_core = net_core self.loop = loop @@ -287,6 +287,9 @@ def __init__(self, account: Account, net_core: NetCore, loop: asyncio.AbstractEv self._status = WsStatus.CLOSED + def set_account(self, new_account: Account) -> None: + self.account = new_account + async def connect(self) -> None: """ 建立weboscket连接 diff --git a/pyproject.toml b/pyproject.toml index dbf1905d..18e11271 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "aiotieba" -version = "4.4.4a3" +version = "4.4.4a4" description = "Asynchronous I/O Client for Baidu Tieba" authors = [{ name = "Starry-OvO", email = "starry.qvq@gmail.com" }] urls = { Repository = "https://github.com/Starry-OvO/aiotieba/", Documentation = "https://aiotieba.cc/" } From d0c3e24ce6273cb082fb743fcf3e08b7de0e2dc5 Mon Sep 17 00:00:00 2001 From: Starry-OvO Date: Sat, 20 Apr 2024 18:08:22 +0800 Subject: [PATCH 10/10] chore: bump client version to 4.4.4 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 18e11271..d89eda8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "aiotieba" -version = "4.4.4a4" +version = "4.4.4" description = "Asynchronous I/O Client for Baidu Tieba" authors = [{ name = "Starry-OvO", email = "starry.qvq@gmail.com" }] urls = { Repository = "https://github.com/Starry-OvO/aiotieba/", Documentation = "https://aiotieba.cc/" }