https://github.com/StarGazer1258/BeatDrop/blob/master/src/actions/queueActions.js
BeatSaberのCustomSongの保存フォルダ名やPlayerData.datのlevelIdとして利用されるSongIDを取得する方法。
曲を整理するスクリプトを書く時に、曲とSongIDの対応をどうやって調べればいいかわからず悩んだが、上URLのBeatDropのソースに書いてあった。dataToHash変数をつかってるあたり。
info.datと各難易度のdatファイル内容をつなげたものからsha1ハッシュを求めればいいらしい。
BeartSaber本体セーブデータにも、どっかにSongIDと曲フォルダの対応データが保存されていると思うんだが、見つけられなかった……。
以下はSongIDを求めるPowerShellスクリプト。
function Get-SongID($info_file_path) {
$info_text = [System.IO.File]::ReadAllText($info_file_path)
$info_json = $info_text | ConvertFrom-Json
$mapFiles = $info_json._difficultyBeatmapSets | % {
$_._difficultyBeatmaps | % {
$_._beatmapFilename
}
}
$info_file_dir = (Get-Item $info_file_path).Directory.FullName
$hash_base_str = ""
$hash_base_str += $info_text
$mapFiles | %{
$hash_base_str += [System.IO.File]::ReadAllText($info_file_dir + "\" + $_)
}
$bytes = [System.Text.Encoding]::UTF8.GetBytes($hash_base_str)
$sha1 = new-object System.Security.Cryptography.SHA1CryptoServiceProvider
$song_hash = ($sha1.ComputeHash($bytes) | % { $_.ToString("x2") }) -join ""
return "custom_level_" + $song_hash
}