Created
June 16, 2024 18:15
-
-
Save taoky/a98233b13a16dd4a50cef202fe46b298 to your computer and use it in GitHub Desktop.
Read osu realm and get audio/bg hashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CollectionDowngrader.LazerSchema from https://github.com/ookiineko/CollectionDowngrader/tree/main/LazerSchema | |
using CollectionDowngrader.LazerSchema; | |
using Realms; | |
// Console.WriteLine($"cwd: {Environment.CurrentDirectory}"); | |
const int LazerSchemaVersion = 41; | |
string realmFile = Path.GetFullPath("./client.realm"); | |
RealmConfiguration config = new(realmFile) | |
{ | |
IsReadOnly = true, | |
SchemaVersion = LazerSchemaVersion, | |
Schema = new[] { | |
typeof(Beatmap), | |
typeof(BeatmapCollection), | |
typeof(BeatmapDifficulty), | |
typeof(BeatmapMetadata), | |
typeof(BeatmapSet), | |
typeof(BeatmapUserSettings), | |
typeof(RealmFile), | |
typeof(RealmNamedFileUsage), | |
typeof(RealmUser), | |
typeof(Ruleset), | |
typeof(ModPreset) | |
} | |
}; | |
Realm db = Realm.GetInstance(config); | |
List<BeatmapCollection> collections = [.. db.All<BeatmapCollection>()]; | |
Console.WriteLine($"Loaded {collections.Count} collections"); | |
foreach (BeatmapCollection collection in collections) { | |
Console.WriteLine($"Collection: {collection.Name}, with {collection.BeatmapMD5Hashes.Count} difficulties"); | |
foreach (string hash in collection.BeatmapMD5Hashes) { | |
Console.WriteLine($" {hash}"); | |
// Search for the beatmap with this hash | |
var beatmaps = db.All<Beatmap>().Where(b => b.MD5Hash == hash).ToList(); | |
foreach (Beatmap beatmap in beatmaps) { | |
if (beatmap.BeatmapSet == null) { | |
continue; | |
} | |
Console.WriteLine($" Beatmap: {beatmap.Metadata.Artist} - {beatmap.Metadata.Title} [{beatmap.DifficultyName}] {beatmap.MD5Hash}"); | |
// Console.WriteLine($" Audio: {beatmap.Metadata.AudioFile}, BG: {beatmap.Metadata.BackgroundFile}"); | |
var audioName = beatmap.Metadata.AudioFile; | |
var bgName = beatmap.Metadata.BackgroundFile; | |
var files = beatmap.BeatmapSet.Files; | |
foreach (RealmNamedFileUsage file in files) { | |
if (file.Filename == audioName) { | |
Console.WriteLine($" Audio: {file.Filename} ({file.File.Hash})"); | |
} | |
if (file.Filename == bgName) { | |
Console.WriteLine($" BG: {file.Filename} ({file.File.Hash})"); | |
} | |
// Console.WriteLine($" File: {file.Filename} ({file.File.Hash})"); | |
} | |
} | |
} | |
} | |
// foreach (Beatmap beatmap in db.All<Beatmap>()) { | |
// Console.WriteLine($"Beatmap: {beatmap.Metadata.Artist} - {beatmap.Metadata.Title} [{beatmap.DifficultyName}] {beatmap.MD5Hash}"); | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment