[![PyPi version](https://badge.fury.io/py/osrparse.svg)](https://pypi.org/project/osrparse/)
# osrparse, a python parser for osu! replays
This is a parser for the ``.osr`` format for osu! replay files, as described by [the wiki](https://osu.ppy.sh/wiki/en/Client/File_formats/Osr_%28file_format%29).
## Installation
To install, simply:
```sh
pip install osrparse
```
## Documentation
Please see the full documentation for a comprehensive guide: <https://kszlim.github.io/osu-replay-parser>. A quickstart follows below for the impatient, but you should read the full documentation if you are at all confused.
### Quickstart
```python
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")
```
Raw data
{
"_id": null,
"home_page": null,
"name": "osrparse",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "osu!, osr, replay, replays, parsing, parser, python",
"author": null,
"author_email": "Kevin Lim <kszlim@gmail.com>, Liam DeVoe <orionldevoe@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/4e/42/c2f93b6fee9b92ac80b8b75724b79422bf5a63d6cb81aeacb63349ca7d4b/osrparse-7.0.1.tar.gz",
"platform": null,
"description": "[![PyPi version](https://badge.fury.io/py/osrparse.svg)](https://pypi.org/project/osrparse/)\n\n# osrparse, a python parser for osu! replays\n\nThis is a parser for the ``.osr`` format for osu! replay files, as described by [the wiki](https://osu.ppy.sh/wiki/en/Client/File_formats/Osr_%28file_format%29).\n\n## Installation\n\nTo install, simply:\n\n```sh\npip install osrparse\n```\n\n## Documentation\n\nPlease see the full documentation for a comprehensive guide: <https://kszlim.github.io/osu-replay-parser>. A quickstart follows below for the impatient, but you should read the full documentation if you are at all confused.\n\n### Quickstart\n\n```python\nfrom osrparse import Replay, parse_replay_data\n# parse from a path\nreplay = Replay.from_path(\"path/to/osr.osr\")\n\n# or from an opened file object\nwith open(\"path/to/osr.osr\") as f:\n replay = Replay.from_file(f)\n\n# or from a string\nwith open(\"path/to/osr.osr\") as f:\n replay_string = f.read()\nreplay = Replay.from_string(replay_string)\n\n# a replay has various attributes\nr = replay\nprint(r.mode, r.game_version, r.beatmap_hash, r.username,\n r.replay_hash, r.count_300, r.count_100, r.count_50,\n r.count_geki, r.count_miss, r.score, r.max_combo, r.perfect,\n r.mods, r.life_bar_graph, r.timestamp, r.replay_data,\n r.replay_id, r.rng_seed)\n\n# parse the replay data from api v1's /get_replay endpoint\nlzma_string = retrieve_from_api()\nreplay_data = parse_replay_data(lzma_string)\n# replay_data is a list of ReplayEvents\n\n# write a replay back to a path\nreplay.write_path(\"path/to/osr.osr\")\n\n# or to an opened file object\nwith open(\"path/to/osr.osr\") as f:\n replay.write_file(f)\n\n# or to a string\npacked = replay.pack()\n\n# edited attributes are saved\nreplay.username = \"fake username\"\nreplay.write_path(\"path/to/new_osr.osr\")\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Parser for osr files and lzma replay streams for osu!",
"version": "7.0.1",
"project_urls": {
"Homepage": "https://github.com/kszlim/osu-replay-parser"
},
"split_keywords": [
"osu!",
" osr",
" replay",
" replays",
" parsing",
" parser",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6aa4aa42de117b3b7460b1f83b6ed0578d0a086245db6e90f6d0503d2057d76f",
"md5": "7eb90ba154fb2707c80cedf1e8d7fa62",
"sha256": "84a0b3377d42751c3bea375b535dda0e71d90a8b378026f2f02b614553bb7163"
},
"downloads": -1,
"filename": "osrparse-7.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7eb90ba154fb2707c80cedf1e8d7fa62",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10486,
"upload_time": "2024-10-09T20:04:56",
"upload_time_iso_8601": "2024-10-09T20:04:56.980081Z",
"url": "https://files.pythonhosted.org/packages/6a/a4/aa42de117b3b7460b1f83b6ed0578d0a086245db6e90f6d0503d2057d76f/osrparse-7.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4e42c2f93b6fee9b92ac80b8b75724b79422bf5a63d6cb81aeacb63349ca7d4b",
"md5": "e4fb884710ceb253028708fea9fc5761",
"sha256": "61e160979c1d1a796a25e83b55effc07ddfadcb126a5cec28b2244cb1b48acdd"
},
"downloads": -1,
"filename": "osrparse-7.0.1.tar.gz",
"has_sig": false,
"md5_digest": "e4fb884710ceb253028708fea9fc5761",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12001,
"upload_time": "2024-10-09T20:04:57",
"upload_time_iso_8601": "2024-10-09T20:04:57.995413Z",
"url": "https://files.pythonhosted.org/packages/4e/42/c2f93b6fee9b92ac80b8b75724b79422bf5a63d6cb81aeacb63349ca7d4b/osrparse-7.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-09 20:04:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kszlim",
"github_project": "osu-replay-parser",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "osrparse"
}