Skip to main content

Parser for osr files and lzma replay streams for osu!

Project description

PyPi version Build Status

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.r_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.r_data, r.r_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


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.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

osrparse-6.0.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file osrparse-6.0.0.tar.gz.

File metadata

  • Download URL: osrparse-6.0.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.0

File hashes

Hashes for osrparse-6.0.0.tar.gz
Algorithm Hash digest
SHA256 2727e56259bc83277cae3312b233e3b357517d99c2904abe04a7872181b4d93d
MD5 b2ba46d4e47fef70b2ff532339e64c82
BLAKE2b-256 cbef108add4870c90a9f1843cbcdfa5e7d42709b3275e2c441194092d5c2e63e

See more details on using hashes here.

File details

Details for the file osrparse-6.0.0-py3-none-any.whl.

File metadata

  • Download URL: osrparse-6.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.0

File hashes

Hashes for osrparse-6.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c92eb577b4d2afc7897f57fcec1db049770fa4973fcfef3516737b7ccca49e8
MD5 fe9b2e75e332813835b42537629384b2
BLAKE2b-256 1d946efa1ff72ccfe1d0b9f4e2c2e144c96c2b7fc5e20d26b72f2b6cd63c9796

See more details on using hashes here.

Supported by

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