Skip to main content

osu-beatmap-preview-py

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

当前为早期开发版本。0.1.12 使用上游 v1.5.7 的固定提交 a4c24e0。 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.12

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.12
File Size Uploaded Provenance Actions
osu_beatmap_preview_py-0.1.12.tar.gz 2.5 MB With provenance Details for osu_beatmap_preview_py-0.1.12.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for osu-beatmap-preview-py 0.1.12
File Actions
osu_beatmap_preview_py-0.1.12-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for osu_beatmap_preview_py-0.1.12-cp310-abi3-win_amd64.whl
osu_beatmap_preview_py-0.1.12-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.12-cp310-abi3-manylinux_2_28_x86_64.whl
osu_beatmap_preview_py-0.1.12-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for osu_beatmap_preview_py-0.1.12-cp310-abi3-manylinux_2_28_aarch64.whl
osu_beatmap_preview_py-0.1.12-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for osu_beatmap_preview_py-0.1.12-cp310-abi3-macosx_11_0_arm64.whl
osu_beatmap_preview_py-0.1.12-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.12-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 29.2 MB

Release files / osu_beatmap_preview_py-0.1.12.tar.gz

Download URL osu_beatmap_preview_py-0.1.12.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
93ada9a180ac46de5146797eed381bae4cb15f5da77f27275566e1f9aa1b54e9
BLAKE2b-256 checksum
How to use checksums
34c203bc9dba092ae0d4a76583d1d62b30bf9ebfbc8fdb9381860716a0a03b05
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 Nov 9, 2026.

Transparency log

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

Download URL osu_beatmap_preview_py-0.1.12-cp310-abi3-win_amd64.whl
Size 5.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ea0c29611347508a73f144ecab01613b4cf6565d18c48c22cf7b1ad15800e2d6
BLAKE2b-256 checksum
How to use checksums
0e4972589fa7077f9095ffc0b41bfe2273e22218eee8d9744b53d40dd2bce245
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 Nov 9, 2026.

Transparency log

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

Download URL osu_beatmap_preview_py-0.1.12-cp310-abi3-manylinux_2_28_x86_64.whl
Size 5.6 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
b87d28376e95bc9428a2de80d8fb4519a1ac843d6b003547b3da89acf98b8f56
BLAKE2b-256 checksum
How to use checksums
17a15cdf3ede9a0f41c0f149a98a3df6d22e33a20197761f908c828de0659a5d
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 Nov 9, 2026.

Transparency log

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

Download URL osu_beatmap_preview_py-0.1.12-cp310-abi3-manylinux_2_28_aarch64.whl
Size 5.4 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
152c9ed0796ad7edfc74ac5c51a495e6fa8d42f4be2eb08e73aebfc79d94aa02
BLAKE2b-256 checksum
How to use checksums
d23aea09d2cb8703188bbea2bd9b735a06137f4b2f6de3faa655ad1f82e311b5
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 Nov 9, 2026.

Transparency log

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

Download URL osu_beatmap_preview_py-0.1.12-cp310-abi3-macosx_11_0_arm64.whl
Size 5.0 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bb6239978894f09317ae3af7f53a11999ef098d648b551af9fb793ab79ba3f7d
BLAKE2b-256 checksum
How to use checksums
7d9f719c5c00cdd167e442170c36b2a948d2ea258a55930e7a6d273426578c9a
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 Nov 9, 2026.

Transparency log

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

Download URL osu_beatmap_preview_py-0.1.12-cp310-abi3-macosx_10_12_x86_64.whl
Size 5.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3a7ef787d0ec299e0ae56697a5c3a62caccd3119d32d762873786d42007abd7b
BLAKE2b-256 checksum
How to use checksums
f73bb2edd9ee2f46a7840fba997b0e03c068cfab046fcc12b7bcb6d9a7c18fe5
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 Nov 9, 2026.

Transparency log

Security for osu-beatmap-preview-py 0.1.12

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.12.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 Nov 9, 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