Skip to main content

DynRender-skia

使用skia渲染BiliBili动态 更新页面效果的优先级会很低

注意

Linux用户在导入skia-python包时可能会遇到以下报错

libGL.so.1: cannot open shared object file: No such file or directory

Windows用户在缺少Microsoft Visual C++ Runtime时可能会遇到以下报错

ImportError: DLL load failed while importing skia: The specified module could not be found.

解决方法

ubuntu用户

apt install libgl1-mesa-glx

ArchLinux用户

pacman -S libgl

centos用户

yum install mesa-libGL -y

Windows用户

下载链接Microsoft Visual C++ 2015 Redistributable Update 3 RC

使用方法

安装必要依赖

pip install dynamicadaptor dynrender-skia

测试

import httpx
import asyncio
import skia
from dynrender_skia.Core import DynRender
from dynamicadaptor.DynamicConversion import formate_message


# 现在风控升级,大概率请求失败,建议携带cookie进行请求
async def web_test():
    dyn_id = "440646043801479846"
    url = f"https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&id={dyn_id}&features=itemOpusStyle"
    headers = {
        "referer": f"https://t.bilibili.com/{dyn_id}",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
    }

    # 发起HTTP请求并解析JSON响应
    message_json = httpx.get(url, headers=headers).json()

    # 格式化消息数据
    message_formate = await formate_message("web", message_json["data"]["item"])

    # 使用DynRender执行动态渲染
    img = await DynRender().run(message_formate)

    # 将渲染后的图像转换为Skia Image对象
    img = skia.Image.fromarray(img, colorType=skia.ColorType.kRGBA_8888_ColorType)

    # 保存图像为PNG文件
    img.save("1.png")


# 当文件作为主程序执行时
if __name__ == "__main__":
    asyncio.run(web_test())

效果展示

示例图片

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dynrender_skia-0.3.1.tar.gz (407.6 kB view details)

Uploaded Source

Built Distribution

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

dynrender_skia-0.3.1-py3-none-any.whl (391.6 kB view details)

Uploaded Python 3

File details

Details for the file dynrender_skia-0.3.1.tar.gz.

File metadata

  • Download URL: dynrender_skia-0.3.1.tar.gz
  • Upload date:
  • Size: 407.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.28.0 CPython/3.13.2 Linux/7.0.0-28-generic

File hashes

Hashes for dynrender_skia-0.3.1.tar.gz
Algorithm Hash digest
SHA256 42be1ea03cb0dde0f3fb5072b5a20b03c3a10c5e499be46838e221ac9abc6374
MD5 f39268bc2d4cbcc5377ae25da0647a75
BLAKE2b-256 48f5300ac67444cab9b67b46ebf8ff87efac2e9e4c7b14be2b645cc229baa576

See more details on using hashes here.

File details

Details for the file dynrender_skia-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: dynrender_skia-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 391.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.28.0 CPython/3.13.2 Linux/7.0.0-28-generic

File hashes

Hashes for dynrender_skia-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d8addb62f298cc0564dac1c514c9692b9bc79f86ae2ca7c4b582b9d30d1f50c
MD5 b4862cf8d802a6bf0255b37e22ae4ed1
BLAKE2b-256 ac2e894c822a5aee64a48c30049fcb14747a9d0a5740ab84bfeaa86cdbfc2be5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 files

0.3.0

1 file

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.8

2 files

0.1.6

2 files

0.1.5

2 files

0.1.2

2 files

0.1.0

2 files

Supported by

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