Skip to main content

BSTokenizer

A Python library for tokenizing and manipulating Beat Saber maps and replays.

Installation

Features

  • Convert Beat Saber maps to and from a token-based representation
  • Support for all common Beat Saber map formats (v2, v3, and v4)
  • Automatic map format conversion between versions
  • Custom data handling for position modifications
  • Extract and manipulate Beat Saber replay data (BSOR format)
  • Utilities for time-to-beat conversions

Basic Usage

Working with Beat Saber Maps

from bstokenizer import BeatSaberMapTokenizer, convert
import json

# Initialize tokenizer
tokenizer = BeatSaberMapTokenizer(default_bpm=120.0) # default_bpm is the same as the Info.dat bpm

# Load map from file
with open('ExpertPlusStandard.dat', 'r') as f:
    map_data = json.load(f)

# Tokenize the map
tokens = tokenizer.tokenize(map_data)

# Manipulate tokens
for token in tokens:
    if token["type"] == "color_note":
        # Modify note positions
        token["x"] += 1

# Convert back to map format
modified_map = tokenizer.detokenize(tokens)

# Convert between map versions
v3_map = convert(map_data, "v3")

Working with Beat Saber Replays

from bstokenizer import BeatSaberReplayTokenizer

# Initialize tokenizer
replay_tokenizer = BeatSaberReplayTokenizer()

# Load replay from file
replay_tokens = replay_tokenizer.tokenize("path/to/replay.bsor")

# Analyze replay data
for token in replay_tokens:
    if token["type"] == "note":
        # Access note cut data
        if "cut" in token:
            print(f"Note at {token['time']}s - Score: {token['score']}")

For Developers

Running Tests

Ensure your changes work correctly by running the test suite:

# Run all tests
pytest bstokenizer/tests/test.py

# Run with verbose output
pytest -v bstokenizer/tests/test.py

Development Setup

  1. Clone the repository
  2. Install development dependencies:
    pip install -e ".[dev]"
    

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for your changes
  4. Ensure all tests pass
  5. Submit a pull request

Requirements

  • Python 3.7+
  • py-bsor library for replay handling

License

MIT

Release files for bstokenizer 0.1.3

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

Source distribution (sdist)

Source distribution for bstokenizer 0.1.3
File Size Uploaded
bstokenizer-0.1.3.tar.gz 22.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bstokenizer 0.1.3
File Interpreter ABI Platform
bstokenizer-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 46.2 kB

Release files / bstokenizer-0.1.3.tar.gz

Download URL bstokenizer-0.1.3.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
00c67f2aba3490d2221bf75355aab38e6ccd5365f1fcd707566cd81a56dc9aad
BLAKE2b-256 checksum
How to use checksums
0eba8db80ae70f236e94a7d5ffef690a23725844d9dbdbb9cae746e8038990d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.8

Release files / bstokenizer-0.1.3-py3-none-any.whl

Download URL bstokenizer-0.1.3-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad91fcf2938b0aa4eba06893d2f545ae07e4dc45b1e7c142cc5816d126f2c491
BLAKE2b-256 checksum
How to use checksums
8b71b0877caa3b215baa33e6d72112c8d50e4a7fcd29a3e4b87a90afafc9be66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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