def textChanged(self, p_str): super().textChanged(p_str) mods = mod_string_to_enums(p_str) if Info.replay is not None: if p_str == "": Info.replay.mod_combination = Info.real_mod else: Info.replay.mod_combination = mods if not EndTimeSlider.objs or not StartTimeSlider.objs: return # hmmmmmmmmmmm prevmax = EndTimeSlider.objs[0].maximum() prevstart = StartTimeSlider.objs[0].value() prevend = EndTimeSlider.objs[0].value() if current_config["End time"] == -1: prevend = -1 StartTimeSlider.objs[0].updatetime() EndTimeSlider.objs[0].updatetime() EndTimeSlider.objs[0].updateendtime() scale = EndTimeSlider.objs[0].maximum() / prevmax StartTimeSlider.objs[0].setValue(prevstart * scale) current_config["Start time"] = prevstart * scale / 1000 if prevend != -1: EndTimeSlider.objs[0].setValue(prevend * scale) current_config["End time"] = prevend * scale / 1000
def toggle_auto(self, enable_auto): if enable_auto: self.prevreplay = "auto" self.setreplay("auto") self.setmap("") Info.replay = Replay() Info.replay.mod_combination = mod_string_to_enums(current_settings["Custom mods"]) Info.map = None Info.maphash = None self.osrgraybutton.show() self.osrbutton.hide() self.mapsetbutton.hide() self.osumapbutton.show() else: self.setreplay("") self.setmap("") current_settings["Custom mods"] = "" current_config[".osr path"] = "" current_config["Beatmap path"] = "" Info.replay = None Info.real_mod = None Info.map = None Info.maphash = None self.check_replay_map() self.osrgraybutton.hide() self.osrbutton.show() self.mapsetbutton.show() self.osumapbutton.hide()
def parse_osr(config, settings): try: logging.info(config[".osr path"]) Info.replay = osrparse.parse_replay_file(config[".osr path"]) Info.real_mod = Info.replay.mod_combination if settings["Custom mods"] != "": Info.replay.mod_combination = mod_string_to_enums( settings["Custom mods"]) return True except Exception as e: logging.error(repr(e)) return False
def __init__(self, data=None, gameplaysettings=None, ppsettings=None, strainsettings=None, filedata=None, filesettings=None, filepp=None, filestrain=None, logtofile=False, enablelog=True, logpath=""): self.settings = Settings() sys.excepthook = excepthook self.settings.path = os.path.dirname( os.path.abspath(inspect.getsourcefile(Dummy))) self.settings.path = os.path.relpath(self.settings.path) if self.settings.path[-1] != "/" and self.settings.path[-1] != "\\": self.settings.path += "/" if logpath == "": logpath = os.path.join(self.settings.path, "logosr2mp4.log") logging.getLogger(PIL.__name__).setLevel(logging.WARNING) fmt = logging.Formatter( "%(asctime)s:%(levelname)s:%(name)s:%(funcName)s:%(message)s") logger.setLevel(TRACE) if logtofile: handler = logging.FileHandler(logpath) elif enablelog: handler = logging.StreamHandler(sys.stdout) else: handler = logging.NullHandler() logger.handlers.clear() handler.setFormatter(fmt) logger.addHandler(handler) self.settings.enablelog = enablelog self.settings.temp = os.path.join(self.settings.path, str(uuid.uuid1()) + "temp/") self.__log.info("test") setup_dir(self.settings) atexit.register(self.cleanup) if gameplaysettings is None: gameplaysettings = defaultsettings if ppsettings is None: ppsettings = defaultppconfig if strainsettings is None: strainsettings = defaultstrainconfig if filedata is not None: data = read(filedata) if filesettings is not None: gameplaysettings = read(filesettings) if filepp is not None: ppsettings = read(filepp) if filestrain is not None: strainsettings = read(filestrain) if os.path.isdir(data["Output path"]): data["Output path"] = os.path.join(data["Output path"], "output.avi") self.data = data replaypath = data[".osr path"] starttime = data["Start time"] endtime = data["End time"] self.settings.codec = data["Video codec"] self.settings.audiocodec = data.get("Audio codec", "aac") self.settings.process = data["Process"] apikey = gameplaysettings["api key"] gameplaysettings["api key"] = None # avoid logging api key self.drawers, self.writers, self.pipes, self.sharedarray = None, None, None, None self.audio = None self.auto = auto = replaypath == "auto" gameplaysettings["Custom mods"] = gameplaysettings.get( "Custom mods", "") self.replayedit = False if not auto: try: self.replay_info = parse_replay_file(replaypath) except FileNotFoundError as e: raise ReplayNotFound() from None reverse_replay = False if gameplaysettings["Custom mods"] != "": self.replayedit = True original = self.replay_info.mod_combination self.replay_info.mod_combination = mod_string_to_enums( gameplaysettings["Custom mods"]) if Mod.HardRock in self.replay_info.mod_combination and Mod.HardRock not in original: reverse_replay = True if Mod.HardRock not in self.replay_info.mod_combination and Mod.HardRock in original: reverse_replay = True setupglobals(self.data, gameplaysettings, self.replay_info.mod_combination, self.settings, ppsettings=ppsettings, strainsettings=strainsettings) self.beatmap_file = get_osu(self.settings.beatmap, self.replay_info.beatmap_hash) self.beatmap = read_file(self.beatmap_file, self.settings.playfieldscale, self.settings.skin_ini.colours, mods=self.replay_info.mod_combination, lazy=False) self.replay_event, self.cur_time = setup_replay( replaypath, self.beatmap, reverse=reverse_replay) self.replay_info.play_data = self.replay_event else: gameplaysettings["Custom mods"] = gameplaysettings.get( "Custom mods", "") mod_combination = mod_string_to_enums( gameplaysettings["Custom mods"]) setupglobals(self.data, gameplaysettings, mod_combination, self.settings, ppsettings=ppsettings, strainsettings=strainsettings) self.beatmap_file = self.settings.beatmap self.settings.beatmap = os.path.dirname(self.settings.beatmap) self.beatmap = read_file(self.beatmap_file, self.settings.playfieldscale, self.settings.skin_ini.colours, mods=mod_combination, lazy=False) self.replay_info = get_auto(self.beatmap) self.replay_info.mod_combination = mod_combination add_useless_shits(self.replay_info.play_data, self.beatmap) self.cur_time = self.replay_info.play_data[0][Replays.TIMES] self.replay_event = self.replay_info.play_data self.start_index, self.end_index = find_time(starttime, endtime, self.replay_event, self.settings) self.starttime, self.endtime = starttime, endtime self.resultinfo = None self.previousprogress = 0 logger.log(TRACE, "Settings vars {}".format(vars(self.settings))) gameplaysettings["api key"] = apikey # restore api key