Skip to content

Commit

Permalink
Merge pull request #195 from Starry-OvO/develop
Browse files Browse the repository at this point in the history
Update 4.4.4
  • Loading branch information
lumina37 authored Apr 20, 2024
2 parents c322902 + d0c3e24 commit de52ae5
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions aiotieba/api/get_bawu_postlogs/_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
from typing import Optional
from urllib.parse import quote

import bs4
import yarl
Expand Down Expand Up @@ -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'),
Expand Down
1 change: 0 additions & 1 deletion aiotieba/api/get_bawu_postlogs/_classdef.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import dataclasses as dcs
from datetime import datetime
from functools import cached_property
from typing import List

import bs4
Expand Down
2 changes: 2 additions & 0 deletions aiotieba/api/get_bawu_userlogs/_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
from typing import Optional
from urllib.parse import quote

import bs4
import yarl
Expand Down Expand Up @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions aiotieba/api/get_posts/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion aiotieba/api/sign_forum/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
16 changes: 14 additions & 2 deletions aiotieba/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
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.58.2.1"
MAIN_VERSION = "12.59.1.0"
POST_VERSION = "12.35.1.0"

APP_SECURE_SCHEME = "https"
Expand Down
11 changes: 8 additions & 3 deletions aiotieba/core/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down
5 changes: 4 additions & 1 deletion aiotieba/core/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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连接
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "aiotieba"
version = "4.4.3"
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/" }
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit de52ae5

Please sign in to comment.