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 = 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 = 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.1.tar.gz
(14.3 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.1.tar.gz.
File metadata
- Download URL: dynamicadaptor-0.1.1.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c726a07a258b55ca58d84605c29fef28eca32a3c2f9811ae85705380771c895
|
|
| MD5 |
5bc2776a4454bd4e9b2d78d90bebc091
|
|
| BLAKE2b-256 |
7ffed9b17a806b7b49c5051fd9792aeab8307c355164cb0214a18fa2e9c0ae2d
|
File details
Details for the file dynamicadaptor-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dynamicadaptor-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03d034aa990ac87214e765ebcd277180eaeabeeabc7193a9476490f1850e7c21
|
|
| MD5 |
9f17430d466f877abf280bebe595d824
|
|
| BLAKE2b-256 |
f99d6b2d1dafb0aa55c7419207742b25168e5b5357e941055853e932daca417e
|