No project description provided
Project description
DynamicAdaptor
用于将bilibili的grpc动态和web动态转换成特定的数据类型
原理说明
将grpc数据转换成json数据,之后使用pydantic进行信息摘要。 web端的json数据同理
下载安装
pip install dynamicadaptor
使用方法
from google.protobuf.json_format import MessageToDict
from dynamicadaptor.DynamicConversion import formate_message
from bilirpc.api import get_dy_detail
import asyncio
import httpx
# 如果数据是grpc返回的数据,则需要转换成json数据
async def sample1():
dynamic_grpc = await get_dy_detail("746530608345251842")
dynamic: dict = MessageToDict(dynamic_grpc[0])
dynamic_formate =await formate_message("grpc", dynamic)
print(dynamic_formate)
asyncio.run(sample1())
# 如果是web返回的数据
async def sample2():
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 =await formate_message("web", result["data"]["item"])
print(dynamic_formate)
asyncio.run(sample2())
License
GPL
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dynamicadaptor-0.1.8.tar.gz
(14.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dynamicadaptor-0.1.8.tar.gz.
File metadata
- Download URL: dynamicadaptor-0.1.8.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
094a14c37575eea9c3399cd4cd31ba4ab438ad65a9231a4a869e18e88290f00c
|
|
| MD5 |
8773af19c92942d97d99473147d8d092
|
|
| BLAKE2b-256 |
3ca67322ec4121e8318aed502b2200b7114ec0452f52f36c299eb5950f42ec06
|
File details
Details for the file dynamicadaptor-0.1.8-py3-none-any.whl.
File metadata
- Download URL: dynamicadaptor-0.1.8-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cdb56e6ba9a5f9ba86c555c3bb49d1a1026e4348b93963af623813485904487
|
|
| MD5 |
a3048d42b416a3c8ffed4e14f75f9749
|
|
| BLAKE2b-256 |
85839e6bd127a3fb3348bd6ee75578d43f3d214b08e0ea55a9eeb327dc3176ca
|