├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── merge_scores └── __main__.py ├── osu_db_tools ├── __init__.py ├── buffer.py ├── merge_scores.py ├── osu_to_sqlite.py ├── parse_scores.py ├── read_collection.py ├── run_tests.py └── score.py ├── osu_to_sqlite └── __main__.py ├── pyproject.toml └── read_collection └── __main__.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | ko_fi: wayson 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 jason wong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # osu-db-tools 2 | 3 | This is my collection of libraries and scripts for manipulating the osu! .db files. 4 | 5 | 6 | ## Installation 7 | ``` 8 | pip install git+https://github.com/jaasonw/osu-db-tools.git 9 | ``` 10 | 11 | I may or may not add more in the future, depending on my personal needs or future 12 | project ideas (Feel free to suggest some!) 13 | 14 | Here's an overview of what's included so far 15 | 16 | | Function | Usage | 17 | | -------------------------------------------------------------------------- |-----------------------------------------------------------------------------------| 18 | | Utility functions for reading/writing binary data from all osu `.db` files | `from osu_db_tools import buffer` | 19 | | Merging 2 `score.db` files | `python -m merge_scores ` | 20 | | Export `osu.db` beatmap data to an sqlite3 database | `python -m osu_to_sqlite ` | 21 | | Export `collection.db` to json | `python -m read_collection ` | 22 | | Export `collection.db` to dict | `from osu_db_tools.read_collection import read_collection`
` read_collection("collection.db")` | 23 | -------------------------------------------------------------------------------- /merge_scores/__main__.py: -------------------------------------------------------------------------------- 1 | from osu_db_tools.merge_scores import main 2 | 3 | main() 4 | -------------------------------------------------------------------------------- /osu_db_tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaasonw/osu-db-tools/c31bbef20661920a001e8b2a98abffb4e8a19170/osu_db_tools/__init__.py -------------------------------------------------------------------------------- /osu_db_tools/buffer.py: -------------------------------------------------------------------------------- 1 | import struct 2 | 3 | 4 | def read_bool(buffer) -> bool: 5 | return struct.unpack(" int: 8 | return struct.unpack(" int: 11 | return struct.unpack(" int: 14 | return struct.unpack(" float: 17 | return struct.unpack(" float: 20 | return struct.unpack(" int: 23 | return struct.unpack(" str: 40 | strlen = 0 41 | strflag = read_ubyte(buffer) 42 | if (strflag == 0x0b): 43 | strlen = 0 44 | shift = 0 45 | # uleb128 46 | # https://en.wikipedia.org/wiki/LEB128 47 | while True: 48 | byte = read_ubyte(buffer) 49 | strlen |= ((byte & 0x7F) << shift) 50 | if (byte & (1 << 7)) == 0: 51 | break 52 | shift += 7 53 | return (struct.unpack("<" + str(strlen) + "s", buffer.read(strlen))[0]).decode("utf-8") 54 | 55 | class WriteBuffer: 56 | def __init__(self): 57 | self.offset = 0 58 | self.data = b"" 59 | 60 | def write_bool(self, data: bool): 61 | self.data += struct.pack(" 0: 83 | self.write_ubyte(0x0b) 84 | strlen = b"" 85 | value = len(data.encode('utf-8')) 86 | while value != 0: 87 | byte = (value & 0x7F) 88 | value >>= 7 89 | if value != 0: 90 | byte |= 0x80 91 | strlen += struct.pack(" 0: 24 | print("added", counter, 25 | "score(s) from beatmap with hash:", md5) 26 | maps1[md5].sort(key = lambda score: score.replay_score, reverse = True) 27 | for md5 in maps2: 28 | if md5 not in maps1: 29 | maps1[md5] = maps2[md5] 30 | print("added", len(maps2[md5]), 31 | "score(s) from beatmap with hash:", md5) 32 | return maps1 33 | 34 | 35 | 36 | def main(): 37 | if (len(sys.argv) != 4): 38 | print("Invalid args: merge_scores.py ") 39 | else: 40 | beatmaps1, version1 = unpack_scores(sys.argv[1]) 41 | beatmaps2, version2 = unpack_scores(sys.argv[2]) 42 | 43 | t0 = time.time() 44 | final = merge_scores(beatmaps1, beatmaps2) 45 | t1 = time.time() 46 | print("merge took:", t1 - t0, "seconds") 47 | 48 | pack_scores(final, version1 if version1 > 49 | version2 else version2, sys.argv[3]) 50 | 51 | if __name__ == "__main__": 52 | main() 53 | 54 | -------------------------------------------------------------------------------- /osu_db_tools/osu_to_sqlite.py: -------------------------------------------------------------------------------- 1 | from osu_db_tools import buffer 2 | import sqlite3 3 | import sys 4 | 5 | # osu db can be really big and we probably shouldnt store it in ram 6 | # but we still want to be able to query it quickly 7 | # solution: parse the db into an sqlite db 8 | def create_db(filename): 9 | sql = sqlite3.connect("cache.db") 10 | c = sql.cursor() 11 | c.execute(''' SELECT count(name) FROM sqlite_master WHERE type='table' AND name='maps' ''') 12 | if c.fetchone()[0] == 1: 13 | sql.execute("DROP TABLE maps") 14 | sql.execute(""" 15 | CREATE TABLE maps ( 16 | artist TEXT, 17 | artist_unicode TEXT, 18 | title TEXT, 19 | title_unicode TEXT, 20 | mapper TEXT, 21 | difficulty TEXT, 22 | audio_file TEXT, 23 | md5_hash TEXT, 24 | map_file TEXT, 25 | ranked_status INTEGER, 26 | num_hitcircles INTEGER, 27 | num_sliders INTEGER, 28 | num_spinners INTEGER, 29 | last_modified INTEGER, 30 | approach_rate NUMERIC, 31 | circle_size NUMERIC, 32 | hp_drain NUMERIC, 33 | overall_difficulty NUMERIC, 34 | slider_velocity NUMERIC, 35 | drain_time INTEGER, 36 | total_time INTEGER, 37 | preview_time INTEGER, 38 | beatmap_id INTEGER, 39 | beatmap_set_id INTEGER, 40 | thread_id INTEGER, 41 | grade_stadard INTEGER, 42 | grade_taiko INTEGER, 43 | grade_ctb INTEGER, 44 | grade_mania INTEGER, 45 | local_offset INTEGER, 46 | stack_leniency NUMERIC, 47 | gameplay_mode INTEGER, 48 | song_source TEXT, 49 | song_tags TEXT, 50 | online_offset INTEGER, 51 | font TEXT, 52 | is_unplayed INTEGER, 53 | last_played INTEGER, 54 | is_osz2 INTEGER, 55 | folder_name TEXT, 56 | last_checked INTEGER, 57 | ignore_sounds INTEGER, 58 | ignore_skin INTEGER, 59 | disable_storyboard INTEGER, 60 | disable_video INTEGER, 61 | visual_override INTEGER, 62 | last_modified2 INTEGER, 63 | mania_speed INTEGER 64 | ); 65 | """) 66 | with open(filename, "rb") as db: 67 | version = buffer.read_uint(db) 68 | folder_count = buffer.read_uint(db) 69 | account_unlocked = buffer.read_bool(db) 70 | # skip this datetime shit for now (8 bytes) 71 | buffer.read_uint(db) 72 | buffer.read_uint(db) 73 | name = buffer.read_string(db) 74 | num_beatmaps = buffer.read_uint(db) 75 | 76 | for _ in range(num_beatmaps): 77 | artist = buffer.read_string(db) 78 | artist_unicode = buffer.read_string(db) 79 | song_title = buffer.read_string(db) 80 | song_title_unicode = buffer.read_string(db) 81 | mapper = buffer.read_string(db) 82 | difficulty = buffer.read_string(db) 83 | audio_file = buffer.read_string(db) 84 | md5_hash = buffer.read_string(db) 85 | map_file = buffer.read_string(db) 86 | ranked_status = buffer.read_ubyte(db) 87 | num_hitcircles = buffer.read_ushort(db) 88 | num_sliders = buffer.read_ushort(db) 89 | num_spinners = buffer.read_ushort(db) 90 | last_modified = buffer.read_ulong(db) 91 | approach_rate = buffer.read_float(db) 92 | circle_size = buffer.read_float(db) 93 | hp_drain = buffer.read_float(db) 94 | overall_difficulty = buffer.read_float(db) 95 | slider_velocity = buffer.read_double(db) 96 | # skip these int double pairs, personally i dont think they're 97 | # important for the purpose of this database 98 | i = buffer.read_uint(db) 99 | for _ in range(i): 100 | buffer.read_int_double(db) 101 | 102 | i = buffer.read_uint(db) 103 | for _ in range(i): 104 | buffer.read_int_double(db) 105 | 106 | i = buffer.read_uint(db) 107 | for _ in range(i): 108 | buffer.read_int_double(db) 109 | 110 | i = buffer.read_uint(db) 111 | for _ in range(i): 112 | buffer.read_int_double(db) 113 | 114 | drain_time = buffer.read_uint(db) 115 | total_time = buffer.read_uint(db) 116 | preview_time = buffer.read_uint(db) 117 | # skip timing points 118 | # i = buffer.read_uint(db) 119 | for _ in range(buffer.read_uint(db)): 120 | buffer.read_timing_point(db) 121 | beatmap_id = buffer.read_uint(db) 122 | beatmap_set_id = buffer.read_uint(db) 123 | thread_id = buffer.read_uint(db) 124 | grade_standard = buffer.read_ubyte(db) 125 | grade_taiko = buffer.read_ubyte(db) 126 | grade_ctb = buffer.read_ubyte(db) 127 | grade_mania = buffer.read_ubyte(db) 128 | local_offset = buffer.read_ushort(db) 129 | stack_leniency = buffer.read_float(db) 130 | gameplay_mode = buffer.read_ubyte(db) 131 | song_source = buffer.read_string(db) 132 | song_tags = buffer.read_string(db) 133 | online_offset = buffer.read_ushort(db) 134 | title_font = buffer.read_string(db) 135 | is_unplayed = buffer.read_bool(db) 136 | last_played = buffer.read_ulong(db) 137 | is_osz2 = buffer.read_bool(db) 138 | folder_name = buffer.read_string(db) 139 | last_checked = buffer.read_ulong(db) 140 | ignore_sounds = buffer.read_bool(db) 141 | ignore_skin = buffer.read_bool(db) 142 | disable_storyboard = buffer.read_bool(db) 143 | disable_video = buffer.read_bool(db) 144 | visual_override = buffer.read_bool(db) 145 | last_modified2 = buffer.read_uint(db) 146 | scroll_speed = buffer.read_ubyte(db) 147 | 148 | sql.execute( 149 | "INSERT INTO maps VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", 150 | (artist,artist_unicode,song_title,song_title_unicode,mapper,difficulty,audio_file,md5_hash,map_file,ranked_status,num_hitcircles,num_sliders,num_spinners,last_modified,approach_rate,circle_size,hp_drain,overall_difficulty,slider_velocity,drain_time,total_time,preview_time,beatmap_id,beatmap_set_id,thread_id,grade_standard,grade_taiko,grade_ctb,grade_mania,local_offset,stack_leniency,gameplay_mode,song_source,song_tags,online_offset,title_font,is_unplayed,last_played,is_osz2,folder_name,last_checked,ignore_sounds,ignore_skin,disable_storyboard,disable_video,visual_override,last_modified2,scroll_speed) 151 | ) 152 | sql.commit() 153 | sql.close() 154 | 155 | def main(): 156 | if (len(sys.argv) != 2): 157 | print("Invalid args: osu_to_sqlite.py ") 158 | else: 159 | create_db(sys.argv[1]) 160 | 161 | if __name__ == "__main__": 162 | main() 163 | 164 | -------------------------------------------------------------------------------- /osu_db_tools/parse_scores.py: -------------------------------------------------------------------------------- 1 | import os 2 | from typing import List 3 | from typing import Dict 4 | 5 | from osu_db_tools import buffer 6 | from osu_db_tools.buffer import WriteBuffer 7 | from osu_db_tools.score import Score 8 | 9 | 10 | def unpack_scores(filename: str): 11 | # https://osu.ppy.sh/help/wiki/osu!_File_Formats/Db_(file_format)#scores.db 12 | with open(filename, "rb") as db: 13 | version = buffer.read_uint(db) 14 | numOfMaps = buffer.read_uint(db) 15 | beatmaps = {} # beatmaps[md5] = [scores] 16 | for _ in range(numOfMaps): 17 | scores = [] 18 | md5 = buffer.read_string(db) 19 | num_scores = buffer.read_uint(db) 20 | for _ in range(num_scores): 21 | score = Score() 22 | score.mode = buffer.read_ubyte(db) 23 | score.version = buffer.read_uint(db) 24 | score.md5 = buffer.read_string(db) 25 | score.player_name = buffer.read_string(db) 26 | score.replay_md5 = buffer.read_string(db) 27 | score.num_300s = buffer.read_ushort(db) 28 | score.num_100s = buffer.read_ushort(db) 29 | score.num_50s = buffer.read_ushort(db) 30 | score.num_gekis = buffer.read_ushort(db) 31 | score.num_katus = buffer.read_ushort(db) 32 | score.num_misses = buffer.read_ushort(db) 33 | score.replay_score = buffer.read_uint(db) 34 | score.max_combo = buffer.read_ushort(db) 35 | score.perfect_combo = buffer.read_bool(db) 36 | score.mods = buffer.read_uint(db) 37 | score.empty_string = buffer.read_string(db) 38 | score.timestamp = buffer.read_ulong(db) 39 | score.negative_one = buffer.read_uint(db) 40 | score.online_score_id = buffer.read_ulong(db) 41 | 42 | scores.append(score) 43 | # print(score.toJSON()) 44 | beatmaps[md5] = scores 45 | db.close() 46 | return (beatmaps, version) 47 | 48 | 49 | def pack_scores(beatmap_scores: Dict[str, List[Score]], version: int, filename: str): 50 | print("Packing scores to buffer") 51 | b = WriteBuffer() 52 | b.write_uint(version) 53 | b.write_uint(len(beatmap_scores)) 54 | for md5 in beatmap_scores: 55 | b.write_string(md5) 56 | b.write_uint(len(beatmap_scores[md5])) 57 | for score in beatmap_scores[md5]: 58 | b.write_ubyte(score.mode) 59 | b.write_uint(score.version) 60 | b.write_string(score.md5) 61 | b.write_string(score.player_name) 62 | b.write_string(score.replay_md5) 63 | b.write_ushort(score.num_300s) 64 | b.write_ushort(score.num_100s) 65 | b.write_ushort(score.num_50s) 66 | b.write_ushort(score.num_gekis) 67 | b.write_ushort(score.num_katus) 68 | b.write_ushort(score.num_misses) 69 | b.write_uint(score.replay_score) 70 | b.write_ushort(score.max_combo) 71 | b.write_bool(score.perfect_combo) 72 | b.write_uint(score.mods) 73 | b.write_string(score.empty_string) 74 | b.write_ulong(score.timestamp) 75 | b.write_uint(score.negative_one) 76 | b.write_ulong(score.online_score_id) 77 | print("Writing scores to file") 78 | try: 79 | os.remove(filename) 80 | except OSError: 81 | pass 82 | db = open(filename, "xb") 83 | db.write(b.data) 84 | db.close() 85 | pass 86 | -------------------------------------------------------------------------------- /osu_db_tools/read_collection.py: -------------------------------------------------------------------------------- 1 | from osu_db_tools import buffer 2 | import json 3 | import sys 4 | 5 | def collection_to_dict(filename): 6 | collections = {}; 7 | with open(filename, "rb") as db: 8 | collections["version"] = buffer.read_uint(db) 9 | collections["num_collections"] = buffer.read_uint(db) 10 | collections["collections"] = [] 11 | for i in range(collections["num_collections"]): 12 | collection = {} 13 | collection["name"] = buffer.read_string(db) 14 | collection["size"] = buffer.read_uint(db) 15 | collection["hashes"] = [] 16 | for i in range(collection["size"]): 17 | collection["hashes"].append(buffer.read_string(db)) 18 | collections["collections"].append(collection) 19 | return collections 20 | 21 | def main(): 22 | if (len(sys.argv) != 2): 23 | print("Invalid args: read_collection.py ") 24 | else: 25 | 26 | print(json.dumps(collection_to_dict(sys.argv[1]), indent=2)) 27 | 28 | if __name__ == "__main__": 29 | main() 30 | -------------------------------------------------------------------------------- /osu_db_tools/run_tests.py: -------------------------------------------------------------------------------- 1 | import os 2 | import struct 3 | import unittest 4 | 5 | import buffer 6 | from buffer import WriteBuffer 7 | 8 | 9 | class TestReadAndWriteBuffers(unittest.TestCase): 10 | 11 | buf = WriteBuffer() 12 | 13 | def clean_db(self): 14 | try: 15 | os.remove("test.db") 16 | except OSError: 17 | pass 18 | 19 | def test_bytes(self): 20 | print("testing read/write bytes") 21 | self.buf = WriteBuffer() 22 | test = 0x80 23 | self.buf.write_ubyte(test) 24 | 25 | self.clean_db() 26 | 27 | db = open("test.db", "wb") 28 | db.write(self.buf.data) 29 | db.close() 30 | 31 | with open("test.db", "rb") as db: 32 | read = buffer.read_ubyte(db) 33 | db.close() 34 | 35 | print(test, " : ", read) 36 | if (test == read): 37 | print("pass") 38 | else: 39 | print("fail") 40 | 41 | 42 | def test_string(self): 43 | print("testing read/write string") 44 | self.buf = WriteBuffer() 45 | test = "asdfasdfasdfasdf" 46 | self.buf.write_string(test) 47 | 48 | self.clean_db() 49 | 50 | db = open("test.db", "wb") 51 | db.write(self.buf.data) 52 | db.close() 53 | 54 | with open("test.db", "rb") as db: 55 | read = buffer.read_string(db) 56 | db.close() 57 | 58 | print(test, " : ", read) 59 | if (test == read): 60 | print("pass") 61 | else: 62 | print("fail") 63 | -------------------------------------------------------------------------------- /osu_db_tools/score.py: -------------------------------------------------------------------------------- 1 | import json 2 | from typing import List 3 | 4 | 5 | class Score: 6 | mode = -1 7 | version = 0 8 | replay_md5 = "" 9 | md5 = "" 10 | player_name = "" 11 | num_300s = 0 12 | num_100s = 0 13 | num_50s = 0 14 | num_gekis = 0 15 | num_katus = 0 16 | num_misses = 0 17 | replay_score = 0 18 | max_combo = 0 19 | perfect_combo = False 20 | mods = 0 21 | empty_string = "" 22 | timestamp = 0 23 | negative_one = 0xffffffff 24 | online_score_id = 0 25 | 26 | def toJSON(self): 27 | return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) 28 | 29 | def __eq__(self, other): 30 | if self.replay_md5 != "" and other.replay_md5 != "": 31 | return self.replay_md5 == other.replay_md5 32 | else: 33 | return self.replay_score == other.replay_score and self.player_name == other.player_name 34 | 35 | class Beatmap: 36 | md5 = "" 37 | num_scores = 0 38 | scores: List[Score] = [] 39 | 40 | def __eq__(self, other): 41 | return self.md5 == other.md5 42 | -------------------------------------------------------------------------------- /osu_to_sqlite/__main__.py: -------------------------------------------------------------------------------- 1 | from osu_db_tools.osu_to_sqlite import main 2 | 3 | main() 4 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "osu-db-tools" 3 | version = "0.1.0" 4 | description = "A collection of functions and scripts for manipulating the osu! .db files" 5 | authors = ["jaasonw "] 6 | license = "MIT" 7 | readme = "README.md" 8 | packages = [{include = "osu_db_tools"}] 9 | 10 | [tool.poetry.dependencies] 11 | python = "^3.8" 12 | 13 | [tool.poetry.scripts] 14 | merge_scores = "osu_db_tools.merge_scores:main" 15 | osu_to_sqlite = "osu_db_tools.osu_to_sqlite:main" 16 | read_collection = "osu_db_tools.read_collection:main" 17 | 18 | 19 | [build-system] 20 | requires = ["poetry-core"] 21 | build-backend = "poetry.core.masonry.api" 22 | -------------------------------------------------------------------------------- /read_collection/__main__.py: -------------------------------------------------------------------------------- 1 | from osu_db_tools.read_collection import main 2 | 3 | main() 4 | --------------------------------------------------------------------------------