DynRender-skia
使用skia渲染BiliBili动态 更新页面效果的优先级会很低
注意
Linux用户在导入skia-python包时可能会遇到以下报错
libGL.so.1: cannot open shared object file: No such file or directory
解决方法
ubuntu用户
apt install libgl1-mesa-glx
ArchLinux用户
pacman -S libgl
centos用户
yum install mesa-libGL -y
使用方法
安装必要依赖
pip install dynamicadaptor dynrender-skia
测试
import httpx
import asyncio
import skia
from dynrender.Core import DynRender
from dynamicadaptor.DynamicConversion import formate_message
# 定义异步函数,用于执行Web测试
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())
效果展示
Metadata
Release files for dynrender-skia-opt 0.3.8
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 |
|---|---|---|---|---|
| dynrender_skia_opt-0.3.8.tar.gz | 366.9 kB | Without provenance | Details for dynrender_skia_opt-0.3.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dynrender_skia_opt-0.3.8-py3-none-any.whl | Python 3 | none | any | Details for dynrender_skia_opt-0.3.8-py3-none-any.whl |
Total release size: 737.9 kB
Release files / dynrender_skia_opt-0.3.8.tar.gz
| Download URL | dynrender_skia_opt-0.3.8.tar.gz |
|---|---|
| Size | 366.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf403100175ba2347d185e1ecb5c4a216cfcc27d4b291e01026851e45535470e
|
|
BLAKE2b-256 checksum How to use checksums |
fc16204a44b27b293ae6524898ded0500e18df2eee208ea3f956be22bff4d5e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.8.2 CPython/3.10.12
|
Release files / dynrender_skia_opt-0.3.8-py3-none-any.whl
| Download URL | dynrender_skia_opt-0.3.8-py3-none-any.whl |
|---|---|
| Size | 371.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6bb3417b0a504642e36e130fb0e0ed9fc4da6e13ab54adba0da0f46d19422bbf
|
|
BLAKE2b-256 checksum How to use checksums |
c621d532f470accb898bbd7bc817fd1eec0c057420dae1ca0c0a5cd3bb71c911
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.8.2 CPython/3.10.12
|
Security for dynrender-skia-opt 0.3.8
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.