Skip to main content

A library for tokenizing Beat Saber maps and replays

Project description

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

Project details


Download files

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

Source Distribution

bstokenizer-0.1.1.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

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

bstokenizer-0.1.1-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file bstokenizer-0.1.1.tar.gz.

File metadata

  • Download URL: bstokenizer-0.1.1.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for bstokenizer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 68ed3481f2896b283df69cc8ced0ba083db49e13c9b10efb6f76c54c51cd879f
MD5 1e50ecf7346688a98015d2aefa7909c1
BLAKE2b-256 e2a9a6e828a71ac76c548c12968c2817d42788fbf1e66db84c0783ca7d80f430

See more details on using hashes here.

File details

Details for the file bstokenizer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bstokenizer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for bstokenizer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6d3f817d260daf7b900f004257cb7b518f14d8a564952eb393ddb39d61c9a79d
MD5 612d47e68cb4720db83e143b085a2abb
BLAKE2b-256 134133003f734b84387b18f13818757559bdc58b68a5616a54073918881e4d47

See more details on using hashes here.

Supported by

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