DynamicAdaptor
用于将bilibili的grpc动态和web动态转换成特定的数据类型
原理说明
将grpc数据转换成json数据,之后使用pydantic进行信息摘要。 web端的json数据同理
下载安装
pip install dynamicadaptor
使用方法
import httpx
from dynamicadaptor import format_message, formate_message
# web 返回的数据(同步调用)
def sample():
url = "https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&id=746530608345251842"
headers = {
"Referer": "https://t.bilibili.com/746530608345251842"
}
result = httpx.get(url, headers=headers).json()
dynamic_formate = format_message(result["data"]["item"])
print(dynamic_formate)
sample()
# 若你的代码处于异步上下文中,可继续使用向后兼容的异步入口 formate_message:
# async def sample_async():
# result = httpx.AsyncClient().get(url, headers=headers)
# dynamic_formate = await formate_message(result["data"]["item"])
数据结构
message
├─message_type: str
├─message_id:str
├─header: Head
| ├─name: str
| ├─mid: int
| ├─face: Optional[str]
| ├─pub_time: Optional[str]
| ├─pub_ts: Optional[int]
| ├─vip: Optional
| | ├─status: Optional[int]
| | ├─type: int
| | └─vatar_subscript: Optional[int]
| |
| ├─pendant: Optional
| | ├─pid: Optional[int]
| | ├─image: Optional[str]
| | └─pendant_name: Optional[str]
| └─official_verify: Optional
| └─type: int
├─text: Optional
| ├─text: Optional
| ├─topic: Optional
| | └─name: str
| └─rich_text_nodes:Optional[List[RichTextDetail]]
| ├─type: str
| ├─text: str
| ├─orig_text: Optional[str]
| └─emoji: Optional
| ├─icon_url: Optional[str]
| ├─text: Optional[str]
| └─type: Union[int, str, None]
|
├─major: Optional
| ├─type: str
| ├─draw: Optional
| | └─items: List
| | ├─height: int
| | ├─width: int
| | └─src: str
| ├─archive: Optional
| | ├─cover: str
| | ├─title: str
| | ├─desc: Optional[str]
| | ├─duration_text: str
| | └─badge: Optional
| | ├─text: Optional[str]
| | ├─color: Optional[str]
| | └─bg_color: Optional[str]
| ├─live_rcmd: Optional
| | └─content: Json
| | └─live_play_info
| | ├─title: str
| | ├─cover: str
| | └─watched_show
| | └─text_large:str
| ├─article: Optional
| | ├─cover: List[str]
| | ├─title: str
| | ├─desc: str
| | └─label: str
| ├─common: Optional
| | ├─biz_type: int
| | ├─cover: Optional[str]
| | ├─desc: Optional[str]
| | ├─title: Optional[str]
| | └─badge: Optional
| | ├─text: Optional[str]
| | ├─color: Optional[str]
| | └─bg_color: Optional[str]
| ├─music: Optional
| | ├─cover: str
| | ├─label: str
| | └─title: str
| ├─pgc: Optional
| | ├─cover: str
| | ├─title: str
| | ├─badge
| | | ├─text: Optional[str]
| | | ├─color: Optional[str]
| | | └─bg_color: Optional[str]
| | └─stat
| | ├─danmaku: str
| | └─play: str
| ├─medialist: Optional
| | ├─cover: str
| | ├─title: str
| | ├─sub_title: str
| | └─badge
| | ├─text: Optional[str]
| | ├─color: Optional[str]
| | └─bg_color: Optional[str]
| ├─courses: Optional
| | ├─cover: str
| | ├─title: str
| | ├─desc: str
| | ├─sub_title: str
| | └─badge
| | ├─text: Optional[str]
| | ├─color: Optional[str]
| | └─bg_color: Optional[str]
| └─live
| ├─cover: str
| ├─title: str
| ├─desc_first: str
| ├─desc_second: str
| └─badge
| ├─text: Optional[str]
| ├─color: Optional[str]
| └─bg_color: Optional[str]
├─additional: Optional
| ├─type: str
| ├─goods: Optional
| | ├─head_text: str
| | └─items: List
| | ├─cover: str
| | ├─price: str
| | └─name: str
| ├─reserve: Optional
| | ├─title: str
| | ├─desc1
| | | └─text: str
| | └─desc2
| | └─text: str
| ├─common
| | ├─sub_type: str
| | ├─head_text: Optional[str]
| | ├─cover: str
| | ├─desc1: str
| | ├─desc2: Optional[str]
| | └─title: str
| ├─ugc
| | ├─cover: str
| | ├─title: str
| | ├─desc_second: str
| | ├─duration: str
| | └─head_text: Optional[str]
| └─vote
| ├─desc: str
| └─join_num: int
└─forward: Optional
├─message_type: str
├─message_id:str
├─header: Head
| ├─name: str
| ├─mid: int
| ├─face: Optional[str]
| ├─pub_time: Optional[str]
| ├─pub_ts: Optional[int]
| ├─vip: Optional
| | ├─status: Optional[int]
| | ├─type: int
| | └─vatar_subscript: Optional[int]
| |
| ├─pendant: Optional
| | ├─pid: Optional[int]
| | ├─image: Optional[str]
| | └─pendant_name: Optional[str]
| └─official_verify: Optional
| └─type: int
├─text: Optional
| ├─text: Optional
| ├─topic: Optional
| | └─name: str
| └─rich_text_nodes:Optional[List[RichTextDetail]]
| ├─type: str
| ├─text: str
| ├─orig_text: Optional[str]
| └─emoji: Optional
| ├─icon_url: Optional[str]
| ├─text: Optional[str]
| └─type: Union[int, str, None]
|
├─major: Optional
| ├─type: str
| ├─draw: Optional
| | └─items: List
| | ├─height: int
| | ├─width: int
| | └─src: str
| ├─archive: Optional
| | ├─cover: str
| | ├─title: str
| | ├─desc: Optional[str]
| | ├─duration_text: str
| | └─badge: Optional
| | ├─text: Optional[str]
| | ├─color: Optional[str]
| | └─bg_color: Optional[str]
| ├─live_rcmd: Optional
| | └─content: Json
| | └─live_play_info
| | ├─title: str
| | ├─cover: str
| | └─watched_show
| | └─text_large:str
| ├─article: Optional
| | ├─cover: List[str]
| | ├─title: str
| | ├─desc: str
| | └─label: str
| ├─common: Optional
| | ├─biz_type: int
| | ├─cover: Optional[str]
| | ├─desc: Optional[str]
| | ├─title: Optional[str]
| | └─badge: Optional
| | ├─text: Optional[str]
| | ├─color: Optional[str]
| | └─bg_color: Optional[str]
| ├─music: Optional
| | ├─cover: str
| | ├─label: str
| | └─title: str
| ├─pgc: Optional
| | ├─cover: str
| | ├─title: str
| | ├─badge
| | | ├─text: Optional[str]
| | | ├─color: Optional[str]
| | | └─bg_color: Optional[str]
| | └─stat
| | ├─danmaku: str
| | └─play: str
| ├─medialist: Optional
| | ├─cover: str
| | ├─title: str
| | ├─sub_title: str
| | └─badge
| | ├─text: Optional[str]
| | ├─color: Optional[str]
| | └─bg_color: Optional[str]
| ├─courses: Optional
| | ├─cover: str
| | ├─title: str
| | ├─desc: str
| | ├─sub_title: str
| | └─badge
| | ├─text: Optional[str]
| | ├─color: Optional[str]
| | └─bg_color: Optional[str]
| └─live
| ├─cover: str
| ├─title: str
| ├─desc_first: str
| ├─desc_second: str
| └─badge
| ├─text: Optional[str]
| ├─color: Optional[str]
| └─bg_color: Optional[str]
└─additional: Optional
├─type: str
├─goods: Optional
| ├─head_text: str
| └─items: List
| ├─cover: str
| ├─price: str
| └─name: str
├─reserve: Optional
| ├─title: str
| ├─desc1
| | └─text: str
| └─desc2
| └─text: str
├─common
| ├─sub_type: str
| ├─head_text: Optional[str]
| ├─cover: str
| ├─desc1: str
| ├─desc2: Optional[str]
| └─title: str
├─ugc
| ├─cover: str
| ├─title: str
| ├─desc_second: str
| ├─duration: str
| └─head_text: Optional[str]
└─vote
├─desc: str
└─join_num: int
License
GPL
Metadata
Release files for DynamicAdaptor 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dynamicadaptor-0.6.1.tar.gz | 20.3 kB | Without provenance | Details for dynamicadaptor-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dynamicadaptor-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for dynamicadaptor-0.6.1-py3-none-any.whl |
Total release size: 36.3 kB
Release files / dynamicadaptor-0.6.1.tar.gz
| Download URL | dynamicadaptor-0.6.1.tar.gz |
|---|---|
| Size | 20.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1612cc245abb512e30756e9d24c317c2e2b402aaa78c1f1ee2eae4ff0ef00382
|
|
BLAKE2b-256 checksum How to use checksums |
c6579bf09d209c69f8e9365bd5d7eda90394a5ae2d129a40a3d75318b1736c0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.28.0 CPython/3.12.3 Linux/6.8.0-134-generic
|
Release files / dynamicadaptor-0.6.1-py3-none-any.whl
| Download URL | dynamicadaptor-0.6.1-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17ba2d3f48205a79edc2388c234bc6e8e3a680d0d6579fc7e3de5897d579aaef
|
|
BLAKE2b-256 checksum How to use checksums |
1fc79304b898f22601eb4b80cbb527c77acf09a4b03d5b4591353c07a86edfab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.28.0 CPython/3.12.3 Linux/6.8.0-134-generic
|
Security for DynamicAdaptor 0.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.