Skip to main content

No project description provided

Project description

DynamicAdaptor


用于将bilibili的grpc动态和web动态转换成特定的数据类型

原理说明

将grpc数据转换成json数据,之后使用pydantic进行信息摘要。 web端的json数据同理

下载安装

pip install BiliDynamicAdaptor

使用方法

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


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.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamicadaptor-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file dynamicadaptor-0.1.0.tar.gz.

File metadata

  • Download URL: dynamicadaptor-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.6 Linux/5.15.0-56-generic

File hashes

Hashes for dynamicadaptor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d85864dab2875a557e07b69df6b4e4dbff160cdf407201a983874b86e8578fac
MD5 bb33302ba5b0cf1aadffc84b79ea5a70
BLAKE2b-256 6e18d34bce06a47dfa059c8dd12f141bc53caf2f494553d1f9dce09a9c76486c

See more details on using hashes here.

File details

Details for the file dynamicadaptor-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dynamicadaptor-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.6 Linux/5.15.0-56-generic

File hashes

Hashes for dynamicadaptor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0a4334fd5383901ac50d49265e6edf9981ed439f519ae02029e2ecacce61633
MD5 d522036fcf9fe0c92791a5fef03cd39f
BLAKE2b-256 b6c0797f0757456b0d15c5423e015634934e42301d2cfee92ac352daa0d7d583

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page