Parser for osr files and lzma replay streams for osu!
Project description
osrparse, a python parser for osu! replays
This is a parser for the .osr
format for osu! replay files, as described by the wiki.
Installation
To install, simply:
pip install osrparse
Documentation
Please see the full documentation for a comprehensive guide: https://kevin-lim.ca/osu-replay-parser/. A quickstart follows below for the impatient, but you should read the full documentation if you are at all confused.
Quickstart
from osrparse import Replay, parse_replay_data
# parse from a path
replay = Replay.from_path("path/to/osr.osr")
# or from an opened file object
with open("path/to/osr.osr") as f:
replay = Replay.from_file(f)
# or from a string
with open("path/to/osr.osr") as f:
replay_string = f.read()
replay = Replay.from_string(replay_string)
# a replay has various attributes
r = replay
print(r.mode, r.game_version, r.beatmap_hash, r.username,
r.replay_hash, r.count_300, r.count_100, r.count_50,
r.count_geki, r.count_miss, r.score, r.max_combo, r.perfect,
r.mods, r.life_bar_graph, r.timestamp, r.replay_data,
r.replay_id, r.rng_seed)
# parse the replay data from api v1's /get_replay endpoint
lzma_string = retrieve_from_api()
replay_data = parse_replay_data(lzma_string)
# replay_data is a list of ReplayEvents
# write a replay back to a path
replay.write_path("path/to/osr.osr")
# or to an opened file object
with open("path/to/osr.osr") as f:
replay.write_file(f)
# or to a string
packed = replay.pack()
# edited attributes are saved
replay.username = "fake username"
replay.write_path("path/to/new_osr.osr")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
osrparse-6.0.1.tar.gz
(10.9 kB
view details)
Built Distribution
osrparse-6.0.1-py3-none-any.whl
(11.8 kB
view details)
File details
Details for the file osrparse-6.0.1.tar.gz
.
File metadata
- Download URL: osrparse-6.0.1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3acc85ab0b4c1595c0521b66034c0929760b94585f275033707ba50a5f3e6489 |
|
MD5 | 6ee2400c7bb40d1cd8c3af2bf67cf53e |
|
BLAKE2b-256 | 2f18fdf38f2cb287ed4e1c6a85b8ee674dc13b360d19145de6ec22fd5b418254 |
File details
Details for the file osrparse-6.0.1-py3-none-any.whl
.
File metadata
- Download URL: osrparse-6.0.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21d7705baf6b72811d555ca3977bfcf1bf14b391da3c931af4b56b2cdd833fea |
|
MD5 | bc93ada36232be973c16b7cc0c662dc2 |
|
BLAKE2b-256 | 28a74a751ed6f7f76dbeef980e33f2e2db0271303be496c9c3f2331b7b56347b |