Appendix

Replay

class osrparse.replay.Replay(mode: osrparse.utils.GameMode, game_version: int, beatmap_hash: str, username: str, replay_hash: str, count_300: int, count_100: int, count_50: int, count_geki: int, count_katu: int, count_miss: int, score: int, max_combo: int, perfect: bool, mods: osrparse.utils.Mod, life_bar_graph: Optional[List[osrparse.utils.LifeBarState]], timestamp: datetime.datetime, replay_data: List[osrparse.utils.ReplayEvent], replay_id: int, rng_seed: Optional[int])[source]

A replay found in a .osr file, or following the osr format. To create a replay, you likely want Replay.from_path, Replay.from_file, or Replay.from_string.

mode

The game mode this replay was played on.

Type

GameMode

game_version

The game version this replay was played on.

Type

int

beatmap_hash

The hash of the beatmap this replay was played on.

Type

str

username

The user that played this replay.

Type

str

replay_hash

The hash of this replay.

Type

str

count_300

The number of 300 judgments in this replay.

Type

int

count_100

The number of 100 judgments in this replay.

Type

int

count_50

The number of 50 judgments in this replay.

Type

int

count_geki

The number of geki judgments in this replay.

Type

int

count_katu

The number of katu judgments in this replay.

Type

int

count_miss

The number of misses in this replay.

Type

int

score

The score of this replay.

Type

int

max_combo

The maximum combo attained in this replay.

Type

int

perfect

Whether this replay was perfect or not.

Type

bool

mods

The mods this replay was played with.

Type

Mod

life_bar_graph

The life bar of this replay over time.

Type

Optional[List[LifeBarState]]

replay_data

The replay data of the replay, including cursor position and keys pressed.

Type

List[ReplayEvent]

replay_id

The replay id of this replay, or 0 if not submitted.

Type

int

rng_seed

The rng seed of this replay, or None if not present (typically not present on older replays).

Type

Optional[int]

static from_path(path)[source]

Creates a new Replay object from the .osr file at the given path.

Parameters

path (str or os.PathLike) – The path to the osr file to read from.

Returns

The parsed replay object.

Return type

Replay

static from_file(file)[source]

Creates a new Replay object from an open file object.

Parameters

file (file-like) – The file object to read from.

Returns

The parsed replay object.

Return type

Replay

static from_string(data)[source]

Creates a new Replay object from a string containing .osr data.

Parameters

data (str) – The data to parse.

Returns

The parsed replay object.

Return type

Replay

write_path(path, *, dict_size=None, mode=None)[source]

Writes the replay to the given path.

Parameters

path (str or os.PathLike) – The path to where to write the replay.

Notes

This uses the current values of any attributes, and so can be used to create an edited version of a replay, by first reading a replay, editing an attribute, then writing the replay back to its file.

write_file(file, *, dict_size=None, mode=None)[source]

Writes the replay to an open file object.

Parameters

file (file-like) – The file object to write to.

pack(*, dict_size=None, mode=None)[source]

Returns the text representing this Replay, in .osr format. The text returned by this method is suitable for writing to a file as a valid .osr file.

Returns

The text representing this Replay, in .osr format.

Return type

str

osrparse.replay.parse_replay_data(data_string, *, decoded=False, decompressed=False, mode=<GameMode.STD: 0>)List[osrparse.utils.ReplayEvent][source]

Parses the replay data portion of a replay from a string. This method is siutable for use with the replay data returned by api v1’s /get_replay endpoint, for instance.

Parameters
  • data_string (str or bytes) – The replay data to parse.

  • decoded (bool) – Whether data_string has already been decoded from a b64 representation. Api v1 returns a base 64 encoded string, for instance.

  • decompressed (bool) – Whether data_string has already been both decompressed from lzma, and decoded to ascii.
    For instance, the following two calls are equivalent: ` >>> parse_replay_data(lzma_string, decoded=True) >>> ... >>> lzma_string = lzma.decompress(lzma_string).decode("ascii") >>> parse_replay_data(lzma_string, decompressed=True) `
    If decompressed is True, decoded is automatically set to True as well (ie, if decompressed is True, we will assume data_string is not base 64 encoded).

  • mode (GameMode) – What mode to parse the replay data as.

Utils

class osrparse.utils.GameMode(value)[source]

An osu! game mode.

class osrparse.utils.Mod(value)[source]

An osu! mod, or combination of mods.

class osrparse.utils.Key(value)[source]

A key that can be pressed during osu!standard gameplay - mouse 1 and 2, key 1 and 2, and smoke.

class osrparse.utils.KeyTaiko(value)[source]

A key that can be pressed during osu!taiko gameplay.

class osrparse.utils.KeyMania(value)[source]

A key that can be pressed during osu!mania gameplay

class osrparse.utils.ReplayEvent(time_delta: int)[source]

Base class for an event (ie a frame) in a replay.

time_delta

The time since the previous event (ie frame).

Type

int

class osrparse.utils.ReplayEventOsu(time_delta: int, x: float, y: float, keys: osrparse.utils.Key)[source]

A single frame in an osu!standard replay.

time_delta

The time since the previous event (ie frame).

Type

int

x

The x position of the cursor.

Type

float

y

The y position of the cursor.

Type

float

keys

The keys pressed.

Type

Key

class osrparse.utils.ReplayEventTaiko(time_delta: int, x: int, keys: osrparse.utils.KeyTaiko)[source]

A single frame in an osu!taiko replay.

time_delta

The time since the previous event (ie frame).

Type

int

x

Unknown what this represents. Always one of 0, 320, or 640, depending on keys.

Type

int

keys

The keys pressed.

Type

KeyTaiko

class osrparse.utils.ReplayEventCatch(time_delta: int, x: float, dashing: bool)[source]

A single frame in an osu!catch replay.

time_delta

The time since the previous event (ie frame).

Type

int

x

The x position of the player.

Type

float

dashing

Whether we are dashing or not.

Type

bool

class osrparse.utils.ReplayEventMania(time_delta: int, keys: osrparse.utils.KeyMania)[source]

A single frame in an osu!mania replay.

time_delta

The time since the previous event (ie frame).

Type

int

keys

The keys pressed.

Type

KeyMania

class osrparse.utils.LifeBarState(time: int, life: float)[source]

A state of the lifebar shown on the results screen, at a particular point in time.

time

The time, in ms, this life bar state corresponds to in the replay. The time since the previous event (ie frame).

Type

int

life

The amount of life at this life bar state.

Type

float