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
.osrfile, or following the osr format. To create a replay, you likely wantReplay.from_path,Replay.from_file, orReplay.from_string.-
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]
-
rng_seed¶ The rng seed of this replay, or
Noneif not present (typically not present on older replays).- Type
Optional[int]
-
static
from_path(path)[source]¶ Creates a new
Replayobject from the.osrfile at the givenpath.- Parameters
path (str or os.PathLike) – The path to the osr file to read from.
- Returns
The parsed replay object.
- Return type
-
static
from_file(file)[source]¶ Creates a new
Replayobject from an open file object.- Parameters
file (file-like) – The file object to read from.
- Returns
The parsed replay object.
- Return type
-
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.
-
-
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_replayendpoint, for instance.- Parameters
decoded (bool) – Whether
data_stringhas already been decoded from a b64 representation. Api v1 returns a base 64 encoded string, for instance.decompressed (bool) – Whether
data_stringhas 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) `
IfdecompressedisTrue,decodedis automatically set toTrueas well (ie, ifdecompressedisTrue, we will assumedata_stringis not base 64 encoded).mode (GameMode) – What mode to parse the replay data as.
Utils¶
-
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.ReplayEvent(time_delta: int)[source]¶ Base class for an event (ie a frame) in a replay.
-
class
osrparse.utils.ReplayEventOsu(time_delta: int, x: float, y: float, keys: osrparse.utils.Key)[source]¶ A single frame in an osu!standard replay.
-
class
osrparse.utils.ReplayEventTaiko(time_delta: int, x: int, keys: osrparse.utils.KeyTaiko)[source]¶ A single frame in an osu!taiko replay.
-
class
osrparse.utils.ReplayEventCatch(time_delta: int, x: float, dashing: bool)[source]¶ A single frame in an osu!catch replay.
-
class
osrparse.utils.ReplayEventMania(time_delta: int, keys: osrparse.utils.KeyMania)[source]¶ A single frame in an osu!mania replay.