beatmap hash fix

This commit is contained in:
Emily 2019-03-13 11:13:55 +01:00
parent 3847689257
commit d1e868c183
3 changed files with 7 additions and 3 deletions

View File

@ -8,7 +8,7 @@ from osuRepy.replay import Replay # Replay instance
from osuRepy.helpers import osuButtons, osuMods # Enum helpers from osuRepy.helpers import osuButtons, osuMods # Enum helpers
replay = Replay() # Create replay instance replay = Replay(beatmap_hash = "9e66c0a0eadced7d07f06b3968a74cc0") # Create replay instance
replay.write( ReplayFrame(2, 256, 192, osuButtons.M1) ) # Add replay frame (time, x, y, buttons) replay.write( ReplayFrame(2, 256, 192, osuButtons.M1) ) # Add replay frame (time, x, y, buttons)

View File

@ -74,6 +74,7 @@ class Replay:
"mode": self.set_mode, "mode": self.set_mode,
"mods": self.set_mods, "mods": self.set_mods,
"osu_version": self.set_osu_version, "osu_version": self.set_osu_version,
"beatmap_hash": self.set_beatmap_hash,
"player_name": self.set_player_name, "player_name": self.set_player_name,
"replay_data": self.write "replay_data": self.write
} }
@ -95,9 +96,12 @@ class Replay:
self._osu_version.value = osu_version self._osu_version.value = osu_version
def set_beatmap_hash(self, md5_hash): def set_beatmap_hash(self, md5_hash):
if type(md5_hash) is bytes:
md5_hash = md5_hash.decode()
if len(md5_hash) != 32 or len([x for x in md5_hash if x in string.hexdigits]) != 32: if len(md5_hash) != 32 or len([x for x in md5_hash if x in string.hexdigits]) != 32:
raise Exception("Invalid beatmap hash") raise Exception("Invalid beatmap hash")
self._beatmap_hash.value = md5_hash self._beatmap_hash.value = md5_hash.encode()
def set_beatmap_file(self, filepath): def set_beatmap_file(self, filepath):
if not isfile(filepath): if not isfile(filepath):

View File

@ -3,7 +3,7 @@ from osuRepy.replay import Replay # Replay instance
from osuRepy.helpers import osuButtons, osuMods # Enum helpers from osuRepy.helpers import osuButtons, osuMods # Enum helpers
replay = Replay() # Create replay instance replay = Replay(beatmap_hash = "9e66c0a0eadced7d07f06b3968a74cc0") # Create replay instance
replay.write( ReplayFrame(2, 256, 192, osuButtons.M1) ) # Add replay frame (time, x, y, buttons) replay.write( ReplayFrame(2, 256, 192, osuButtons.M1) ) # Add replay frame (time, x, y, buttons)