Skip to main content

osu-beatmap-preview-py

osu-beatmap-preview 的 Python 原生扩展。渲染器通过 PyO3 直接运行在 Python 进程内,不需要下载、配置或启动额外的 可执行文件。

当前为早期开发版本。0.1.11 使用上游 main(v1.5.2 之后)的固定提交 4c1df8f。 core、CLI 和构建资源随仓库分发,确保各平台 wheel 使用相同的渲染行为。

安装

pip install osu-beatmap-preview-py

PyPI 发布后,pip 会为受支持的平台安装预编译 wheel,不要求用户安装 Rust。没有预编译 wheel 的平台从源码安装时仍需要 Rust 和 C++ 工具链。

使用

from osu_beatmap_preview import generate_preview_async

result = await generate_preview_async(
    4498112,
    format="gif",
    mods="hd+hr",
    times="preview+60",
    duration_time=8,
    fps=30,
    scale=1.5,
)
print(result["preview-img"])

generate_preview() 是同步接口,适合脚本;NoneBot、FastAPI 等异步应用应使用 generate_preview_async(),避免阻塞事件循环。

convert 仅用于将 osu!standard 谱面转换成 taiko、ctb 或 mania。原生非 standard 谱面不要传入 convert。

times 使用 + 分隔多个秒数,也支持 preview;duration_time 控制 GIF 片段或 MP4 区间时长。config 可传配置文件路径或内联 JSON/YAML,scale 用于临时覆盖输出倍率。

CTB GIF 模组

原生 CTB 和 standard 转 CTB 的 GIF 支持 hd、ez、hr、dt、ht。 HD 会让水果、水滴及香蕉在到达判定线前渐隐;支持 hd+ez、hd+hr、hd+dt、hd+ht。 ez+hr 和 dt+ht 是互斥组合。PNG 静态图支持 EZ、HR,不支持 HD、DT、HT。 Hyperdash(红果)的外圈默认使用红色 #FF0000,可通过 skin.HYPER_DASH 配置 RGB 颜色; 水果本体继续使用谱面 Combo 颜色,HD 渐隐同时作用于本体、白边和红圈。

result = await generate_preview_async(
    3994408,
    format="gif",
    mods="hd+dt",
    times="preview",
    duration_time=3,
    fps=20,
)

四种模式的 GIF / MP4 模组

模式 支持的模组
Standard EZ、HR、HD、FL、MR、TC、DA、DT、HT、NC、DC
Taiko EZ、HR、HD、FL、SW、CS、DT、HT、NC、DC
Catch EZ、HR、HD、FL、DT、HT、NC、DC
Mania HD、FL、1K–10K、DS、IN、HO、MR、CS、DT、HT、NC、DC

组合中的每个模组都必须受当前模式支持;Mania 的 HD+FL 互斥,其余三种模式可组合使用。 HD+TC、IN+HO、EZ+HR、DT+HT 互斥;mania 的键数模组和 DS 只影响 standard 转谱。 GIF 和 MP4 使用相同的模组支持规则,GIF 在 15、30、60 fps 下也会保持请求的播放时长。

DT/HT 的 MP4 音乐保调变速,可用 dt1.25、ht0.9 指定倍速;NC/DC 默认以 1.5x / 0.75x 播放,也可指定倍速,音乐音高倍率固定为 1.5 / 0.75,NC 还叠加节拍鼓点。 速度模组不能混用。 AT 已移除。Standard 通过 render.standard.<format>.style.SHOW_CURSOR 显示自动光标; Catch 的 GIF / MP4 通过 render.catch.<format>.style.SHOW_CATCHER 显示自动接盘。 太鼓 GIF / MP4 默认显示击打按键和音符击飞效果,可通过 SHOW_KEY_OVERLAY、SHOW_HIT_EFFECTS 控制。 自定义配置请以 当前上游配置 为准,旧版部分排版、配色字段已移除。 太鼓 PNG 转盘显示总击打数与时长,GIF 和 MP4 显示完整空心转盘、剩余击打数及完成淡出。 四模式 MP4 可通过 render.<mode>.mp4.style.ENABLE_STORYBOARD 和 ENABLE_BACKGROUND_VIDEO 启用故事板及背景视频, 两项默认关闭;<mode> 为 standard、taiko、catch 或 mania。

Taiko HD 隐藏普通音符和连打刻度,保留连打条与气球;Mania HD 让音符头、长按主体 在判定线附近渐隐,遮罩随连击扩大。HD 不会遮住 Mania 判定线、键道背景或 SV 提示。 Catch HD 在 Kiai 区段持续保留淡淡的物件轮廓,不随 BPM 闪烁;区段结束后恢复普通 HD。 圆形预览样式暂用约 30% 不透明度近似轮廓亮度,不逐像素复刻皮肤的 lighting 纹理。

FL 在 Standard 跟随自动光标(滑条期间额外暗化),在 Catch 跟随接盘,在 Taiko 固定于判定区; Mania FL 只保留中部横向可视带。Standard、Taiko、Catch 在 100/200 combo 时缩小光圈。 预览没有玩家输入或回放,轨迹用谱面物件之间的插值估算,连击按无 miss 进度计算; Standard 的光圈跟随延迟使用连续阻尼近似,Catch 香蕉雨期间沿用相邻水果的插值路线。 Taiko、Catch、Mania 的 PNG 是静态概览,不支持 HD/FL;Standard 的 PNG 快照支持二者。

异步取消与并发

上游 Rust API 当前是同步接口,没有提供取消令牌。取消 generate_preview_async() 所在的 Python task 不会中止已经开始的原生渲染;Bot 集成时应使用 semaphore 限制并发。若需要真正的 超时中止,应先在上游 library API 增加协作式取消能力。

本地开发

uv sync
uv run maturin develop
uv run pytest
cargo test -p osu-beatmap-preview-core -p osu-beatmap-preview-cli

发布

推送 v* tag 后,GitHub Actions 会构建 Windows、Linux 和 macOS wheel,并通过 PyPI Trusted Publishing 发布。发布前需要:

  1. 在 GitHub 创建名为 pypi 的 environment;
  2. 在 PyPI 为该 GitHub 仓库配置 Trusted Publisher;
  3. 确认对应版本已经同时写入 Cargo.toml 和 pyproject.toml。

许可证

本项目采用 MIT License。上游渲染器同样采用 MIT License,版权归其贡献者所有。

Metadata

Release files for osu-beatmap-preview-py 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for osu-beatmap-preview-py 0.1.11
File Size Uploaded Provenance Actions
osu_beatmap_preview_py-0.1.11.tar.gz 2.4 MB With provenance Details for osu_beatmap_preview_py-0.1.11.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for osu-beatmap-preview-py 0.1.11
File Actions
osu_beatmap_preview_py-0.1.11-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for osu_beatmap_preview_py-0.1.11-cp310-abi3-win_amd64.whl
osu_beatmap_preview_py-0.1.11-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for osu_beatmap_preview_py-0.1.11-cp310-abi3-manylinux_2_28_x86_64.whl
osu_beatmap_preview_py-0.1.11-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for osu_beatmap_preview_py-0.1.11-cp310-abi3-manylinux_2_28_aarch64.whl
osu_beatmap_preview_py-0.1.11-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for osu_beatmap_preview_py-0.1.11-cp310-abi3-macosx_11_0_arm64.whl
osu_beatmap_preview_py-0.1.11-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for osu_beatmap_preview_py-0.1.11-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 28.3 MB

Release files / osu_beatmap_preview_py-0.1.11.tar.gz

Download URL osu_beatmap_preview_py-0.1.11.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
c1ac543ff64db381b1b154f6b63d12356ea4ac8212c9fae024041678b99009b0
BLAKE2b-256 checksum
How to use checksums
52234db5e983e6983396167f92bbbd86131d029fe1345eebdeb0a3eb4518dec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.11-cp310-abi3-win_amd64.whl

Download URL osu_beatmap_preview_py-0.1.11-cp310-abi3-win_amd64.whl
Size 5.3 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
edd7aad0c498640d7be18473a4eefb042c6325ebf7cf1008efc7211d4e0248ce
BLAKE2b-256 checksum
How to use checksums
69e6324625a17b7ecb4ce11c90c452af346613031ddb3858e3249f5e95a5fce5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.11-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL osu_beatmap_preview_py-0.1.11-cp310-abi3-manylinux_2_28_x86_64.whl
Size 5.5 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
1410e7c4a6c9a3e48ff73c1d4d23c38a2bff0355fb7cf2b30a2e965d995a685c
BLAKE2b-256 checksum
How to use checksums
80b73e118a9793fe624586f110cf019d27769f56809230eb1249787d2cb1614a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.11-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL osu_beatmap_preview_py-0.1.11-cp310-abi3-manylinux_2_28_aarch64.whl
Size 5.2 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
cb43cccc69d70af81a91e8cc284eab5ca413f63c98f6c2c278dcbaa6731ec007
BLAKE2b-256 checksum
How to use checksums
e44af074756f5d1777e3aaf25fd596cd8ea2ded13bcd0390ecc46c10bdd60012
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.11-cp310-abi3-macosx_11_0_arm64.whl

Download URL osu_beatmap_preview_py-0.1.11-cp310-abi3-macosx_11_0_arm64.whl
Size 4.9 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
10b539b731a56c0369e9b3193339da2c54395db051bc3b762fe3fa6416108696
BLAKE2b-256 checksum
How to use checksums
d369719b1b957eec0d70e2cc87c92f19d4aa502d2492701fc0499f3bd1b33d73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.11-cp310-abi3-macosx_10_12_x86_64.whl

Download URL osu_beatmap_preview_py-0.1.11-cp310-abi3-macosx_10_12_x86_64.whl
Size 5.1 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d34d7ab3bb010a531613de65da0061bd73657eff2e68234c3679e6272da3e501
BLAKE2b-256 checksum
How to use checksums
15f4e0bde3ab0318c5943b2a5d9ef8e849d8f8943e68bfb3cb2b037089c50c46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for osu-beatmap-preview-py 0.1.11

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for osu_beatmap_preview_py-0.1.11.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page