diff --git a/CHANGELOGS/v15.md b/CHANGELOGS/v15.md index 4f20310d..5b58019c 100644 --- a/CHANGELOGS/v15.md +++ b/CHANGELOGS/v15.md @@ -1,3 +1,7 @@ +# 15.5.5 +- fix: user.get_dynamics https://github.com/Nemo2011/bilibili-api/pull/439 +- feat: session.get_at https://github.com/Nemo2011/bilibili-api/pull/443 + # 15.5.4 2023/8/16 - fix: [BREADKING CHANGE] 更新 user.get_dynamics 接口 https://github.com/Nemo2011/bilibili-api/pull/432 - fix: 无法实时获取弹幕 by @Drelf2018 in https://github.com/Nemo2011/bilibili-api/pull/430 and @whille in https://github.com/Nemo2011/bilibili-api/pull/429 diff --git a/bilibili_api/__init__.py b/bilibili_api/__init__.py index 996648e9..adc3256b 100644 --- a/bilibili_api/__init__.py +++ b/bilibili_api/__init__.py @@ -83,7 +83,7 @@ interactive_video, ) -BILIBILI_API_VERSION = "15.5.4" +BILIBILI_API_VERSION = "15.5.5" # 如果系统为 Windows,则修改默认策略,以解决代理报错问题 if "windows" in platform.system().lower(): diff --git a/bilibili_api/data/api/session.json b/bilibili_api/data/api/session.json index 1d8fb4f0..9189b590 100644 --- a/bilibili_api/data/api/session.json +++ b/bilibili_api/data/api/session.json @@ -51,17 +51,23 @@ "comment": "获取点赞" }, "unread": { - "url": "https://api.bilibili.com/x/msgfeed/unread?build=0&mobi_app=web", + "url": "https://api.bilibili.com/x/msgfeed/unread", "method": "GET", "verify": true, "comment": "获取未读的信息" }, "replies": { - "url": "https://api.bilibili.com/x/msgfeed/reply?platform=web&build=0&mobi_app=web", + "url": "https://api.bilibili.com/x/msgfeed/reply", "method": "GET", "verify": true, "comment": "获取收到的回复" }, + "at": { + "url": "https://api.bilibili.com/x/msgfeed/at", + "method": "GET", + "verify": true, + "comment": "获取未读 AT" + }, "system_msg": { "url": "https://message.bilibili.com/x/sys-msg/query_user_notify", "method": "GET", diff --git a/bilibili_api/data/api/user.json b/bilibili_api/data/api/user.json index a748b78a..1bc39ec2 100644 --- a/bilibili_api/data/api/user.json +++ b/bilibili_api/data/api/user.json @@ -174,6 +174,17 @@ "comment": "专栏文集" }, "dynamic": { + "url": "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history", + "method": "GET", + "verify": false, + "params": { + "host_uid": "int: uid", + "offset_dynamic_id": "int: 动态偏移用,第一页为 0", + "need_top": "int bool: 是否显示置顶动态" + }, + "comment": "用户动态信息" + }, + "dynamic_new": { "url": "https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space", "method": "GET", "verify": false, @@ -570,4 +581,4 @@ } } } -} \ No newline at end of file +} diff --git a/bilibili_api/session.py b/bilibili_api/session.py index 01255b1e..d25bbf24 100644 --- a/bilibili_api/session.py +++ b/bilibili_api/session.py @@ -9,7 +9,7 @@ import asyncio import logging import datetime -from typing import Union +from typing import Union, Optional from apscheduler.schedulers.asyncio import AsyncIOScheduler @@ -129,37 +129,74 @@ async def get_session_detail( return await Api(**api, credential=credential).update_params(**params).result -async def get_likes(credential: Credential) -> dict: +async def get_replies( + credential: Credential, + last_reply_id: Optional[int] = None, + reply_time: Optional[int] = None, +) -> dict: + """ + 获取收到的回复 + + Args: + credential (Credential): 凭据类. + + last_reply_id (Optional, int) 最后一个评论的 ID + + reply_time (Optional, int) 最后一个评论发送时间 + + Returns: + dict: 调用 API 返回的结果 + """ + api = API["session"]["replies"] + params = {"id": last_reply_id, "reply_time": reply_time} + return await Api(**api, credential=credential).update_params(**params).result + + +async def get_likes( + credential: Credential, last_id: int = None, like_time: int = None +) -> dict: """ 获取收到的赞 Args: credential (Credential): 凭据类. + last_id (Optional, int) 最后一个 ID + + like_time (Optional, int) 最后一个点赞发送时间 + Returns: dict: 调用 API 返回的结果 """ api = API["session"]["likes"] - return await Api(**api, credential=credential).result + params = {"id": last_id, "like_time": like_time} + return await Api(**api, credential=credential).update_params(**params).result -async def get_unread_messages(credential: Credential) -> dict: +async def get_at( + credential: Credential, last_uid: int = None, at_time: int = None +) -> dict: """ - 获取未读的信息 + 获取收到的 AT Args: credential (Credential): 凭据类. + last_id (Optional, int) 最后一个 ID + + at_time (Optional, int) 最后一个点赞发送时间 + Returns: dict: 调用 API 返回的结果 """ - api = API["session"]["unread"] - return await Api(**api, credential=credential).result + api = API["session"]["at"] + params = {"id": last_uid, "at_time": at_time} + return await Api(**api, credential=credential).update_params(**params).result -async def get_replies(credential: Credential) -> dict: +async def get_unread_messages(credential: Credential) -> dict: """ - 获取收到的回复 + 获取未读的信息 Args: credential (Credential): 凭据类. @@ -167,7 +204,7 @@ async def get_replies(credential: Credential) -> dict: Returns: dict: 调用 API 返回的结果 """ - api = API["session"]["replies"] + api = API["session"]["unread"] return await Api(**api, credential=credential).result diff --git a/bilibili_api/user.py b/bilibili_api/user.py index 7a0a6245..9183cc44 100644 --- a/bilibili_api/user.py +++ b/bilibili_api/user.py @@ -469,13 +469,43 @@ async def get_article_list( api = API["info"]["article_lists"] params = {"mid": self.__uid, "sort": order.value} return await Api(**api, credential=self.credential).update_params(**params).result - - async def get_dynamics(self, offset: int = 0) -> dict: + + async def get_dynamics(self, offset: int = 0, need_top: bool = False) -> dict: """ 获取用户动态。 - + + 建议使用 user.get_dynamics_new() 新接口。 Args: offset (str, optional): 该值为第一次调用本方法时,数据中会有个 next_offset 字段, + 指向下一动态列表第一条动态(类似单向链表)。 + 根据上一次获取结果中的 next_offset 字段值, + 循环填充该值即可获取到全部动态。 + 0 为从头开始。 + Defaults to 0. + need_top (bool, optional): 显示置顶动态. Defaults to False. + Returns: + dict: 调用接口返回的内容。 + """ + api = API["info"]["dynamic"] + params = { + "host_uid": self.__uid, + "offset_dynamic_id": offset, + "need_top": 1 if need_top else 0, + } + data = await Api(**api, credential=self.credential).update_params(**params).result + # card 字段自动转换成 JSON。 + if "cards" in data: + for card in data["cards"]: + card["card"] = json.loads(card["card"]) + card["extend_json"] = json.loads(card["extend_json"]) + return data + + async def get_dynamics_new(self, offset: int = "") -> dict: + """ + 获取用户动态。 + + Args: + offset (str, optional): 该值为第一次调用本方法时,数据中会有个 offset 字段, 指向下一动态列表第一条动态(类似单向链表)。 @@ -483,13 +513,14 @@ async def get_dynamics(self, offset: int = 0) -> dict: 循环填充该值即可获取到全部动态。 - 0 为从头开始。 - Defaults to 0. + 空字符串为从头开始。 + Defaults to "". Returns: dict: 调用接口返回的内容。 """ - api = API["info"]["dynamic"] + self.credential.raise_for_no_sessdata() + api = API["info"]["dynamic_new"] params = { "host_mid": self.__uid, "offset": offset, @@ -497,11 +528,6 @@ async def get_dynamics(self, offset: int = 0) -> dict: "timezone_offset": -480 } data = await Api(**api, credential=self.credential).update_params(**params).result - # card 字段自动转换成 JSON。 - if "cards" in data: - for card in data["cards"]: - card["card"] = json.loads(card["card"]) - card["extend_json"] = json.loads(card["extend_json"]) return data async def get_subscribed_bangumi( diff --git a/index.html b/index.html deleted file mode 100644 index 30f69c96..00000000 --- a/index.html +++ /dev/null @@ -1,991 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - 尼尔:自动人形第2集-番剧-高清独家在线观看-bilibili-哔哩哔哩 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
-
-
- - - - - - - 追番 -
-
-
-
-
-
-
-
-
- - - - -
-
-
尼尔:自动人形
-
- - - - - - - 追番 -
-
-
-
-
- - - - - - 重播 -
-
- - - - - - - 好评 -
-
- - - - - - 投币 -
-
- - - - - - - 分享 -
-
-
-
-
相关推荐
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - - - - - - 投币 - - - - - - - - 用手机观看 - - - -
- - - - 一起看 -
- -
-
-
- - - - - - -
- 尼尔:自动人形 -
-- - - 播放  ·   - - - - - 弹幕  ·   - - -追番 -
-
- 游戏改 / 战斗 / 科幻 / 催泪 - - · - 2023 - - · - 连载中, 每周二 20:00更新 - - · - - - BV1Fu411p7LF - - -
-
声优:2B:石川由依 - 9S:花江夏树 - 辅助机042:安元洋贵 - 辅助机153:秋山薰 - 亚当:浪川大辅 - 夏娃:铃木达央 - 帕斯卡:悠木碧 - 司令官:加纳千秋 - 通讯官60:矶部惠子 - 通讯官210:初美梅亚莉 - 莉莉:种崎敦美
- -
-
-

简介: - - 公元5012年。 - 突然降临的外星人,和其制造的机械生命体,让人类陷入了灭绝的危机。 - 只有极少一部分人类逃到了月球,为了夺回地球,他们使用人造人士兵开始了反攻行动。 - 但是面对能够无限增殖的机械生命体,战斗陷入胶着。 - 为此,人类派遣最终兵器——由新型人造人组成的“寄叶部队”前往地球。 - 刚被派到地球的“2B”和先行调查员“9S”会合,准备执行任务,却在途中遇到了各种难以解释的现象…… - - 这是讲述为人类不停战斗的,没有生命的“人造人”的故事—— -

-
展开
-
-

公元5012年。 - 突然降临的外星人,和其制造的机械生命体,让人类陷入了灭绝的危机。 - 只有极少一部分人类逃到了月球,为了夺回地球,他们使用人造人士兵开始了反攻行动。 - 但是面对能够无限增殖的机械生命体,战斗陷入胶着。 - 为此,人类派遣最终兵器——由新型人造人组成的“寄叶部队”前往地球。 - 刚被派到地球的“2B”和先行调查员“9S”会合,准备执行任务,却在途中遇到了各种难以解释的现象…… - - 这是讲述为人类不停战斗的,没有生命的“人造人”的故事——

-
-
-
-
-
-
- - - - - 番剧 - - 频道 - - -
-
-
-
-
-
-
-
- -
-
-
-
- - - -
-
bilibili点评公测邀请
-
-
-

满足以下条件可以发表点评

-
    -
  • - 1、会员等级不低于Lv4 - - - -
  • -
  • -
    - 2、绑定非虚拟号段手机 - - - -
    - 去绑定手机 -
  • -
-
- -
-
-
-
-
-
-
-
- - - -
-
-
-
-
-
本片为大会员专享影片
-
成为大会员邀请好友一起看哦~
-
成为大会员
-
-
-
-
-
-
- -
-
-
- - - - \ No newline at end of file diff --git a/setup.py b/setup.py index 246f78d1..22008a7a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="bilibili-api-python", - version="15.5.4", + version="15.5.5", license="GPLv3+", author="Nemo2011", author_email="yimoxia@outlook.com",