Ejemplo n.º 1
0
    def __init__(self, width, ppsettings):
        self.background = Image.open(os.path.join(abspath, "res/pppp.png"))
        ratio = self.background.size[1] / self.background.size[0]
        newheight = int(width * ratio)
        self.background = self.background.resize((width, newheight),
                                                 Image.ANTIALIAS)
        self.outputpath = os.path.join(abspath, "ppsample.png")

        settings = Settings()
        settings.path = os.path.dirname(osr2mp4.__file__) + "/"
        width, height = self.background.size
        playfield_scale, playfield_width, playfield_height, scale, move_right, move_down = get_screensize(
            width, height)
        settings.scale = scale
        settings.width = width
        settings.height = height
        settings.settings["Enable PP counter"] = True
        settings.ppsettings = ppsettings
        settings.fps = 60
        settings.timeframe = 1000
        self.ppcounter = PPCounter(settings)
        self.ppcounter.set(727.27)

        self.hitresultcounter = HitresultCounter(settings)
        self.hitresultcounter.set({100: 17, 50: 70, 0: 13})
        self.settings = settings
Ejemplo n.º 2
0
    def setUpClass(cls):
        cls.real = []
        cls.tests = []
        cls.custom = []
        cls.custom_expect100 = [
            0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1,
            1, 0
        ]
        cls.custom_expect50 = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0
        ]
        cls.settings = Settings()
        cls.settings.timeframe = 1000
        cls.settings.fps = 60
        cls.tests.append(getinfos("yomi"))
        cls.tests.append(getinfos("tool"))
        cls.tests.append(getinfos("2tool"))
        cls.tests.append(getinfos("2yomi"))
        cls.tests.append(getinfos("4yomi"))

        cls.custom.append(getinfos("69tool"))
        cls.custom.append(getinfos("69yomi", True))
        cls.custom.append(getinfos("70tool"))
        cls.custom.append(getinfos("71tool"))
        cls.custom.append(getinfos("69kikoku"))
        cls.custom.append(getinfos("70kikoku"))
        cls.custom.append(getinfos("71kikoku"))
        cls.custom.append(getinfos("72yomi", True))
        cls.custom.append(getinfos("73yomi", True))
        cls.custom.append(getinfos("74yomi", True))
        cls.custom.append(getinfos("75yomi", True))
        cls.custom.append(getinfos("76yomi", True))
        cls.custom.append(getinfos("77yomi", True))
        cls.custom.append(getinfos("72tool"))
        cls.custom.append(getinfos("73tool"))
        cls.custom.append(getinfos("74tool"))
        cls.custom.append(getinfos("75tool"))
        cls.custom.append(getinfos("76tool"))
        cls.custom.append(getinfos("72kikoku"))
        cls.custom.append(getinfos("blends"))
        cls.custom.append(getinfos("date"))
        cls.custom.append(getinfos("69reimei"))
        cls.custom.append(getinfos("73kikoku"))
        cls.custom.append(getinfos("74kikoku"))

        cls.real.append(getinfos("realtool"))
        cls.real.append(getinfos("realyomi", True))
        cls.real.append(getinfos("realkikoku"))
        cls.real.append(getinfos("realmagnolia"))
        cls.real.append(getinfos("realkaede"))
        cls.real.append(getinfos("realexit"))
        cls.real.append(getinfos("realfallen"))
Ejemplo n.º 3
0
 def setUpClass(cls):
     cls.tests = []
     cls.settings = Settings()
     cls.settings.timeframe = 1000
     cls.settings.fps = 60
     cls.tests.append(getinfos("milkcrown", hr=True))
     cls.tests.append(getinfos("future", hr=True, dt=True))
     cls.tests.append(getinfos("bubble", hr=True))
     cls.tests.append(getinfos("badeustack", hr=True, dt=True))
     cls.tests.append(getinfos("heyroniistack", dt=True))
     cls.tests.append(getinfos("woeystack", dt=True))
     cls.tests.append(getinfos("willstack", hr=True))
     cls.tests.append(getinfos("vaxeistack", hr=True))
Ejemplo n.º 4
0
 def setUpClass(cls):
     cls.tests = []
     cls.settings = Settings()
     cls.settings.timeframe = 1000
     cls.settings.fps = 60
     cls.tests.append(getinfos("dearbrave"))
     cls.tests.append(getinfos("2dearbrave"))
     cls.tests.append(getinfos("3dearbrave"))
     cls.tests.append(getinfos("4dearbrave"))
     cls.tests.append(getinfos("5dearbrave"))
     cls.tests.append(getinfos("yomi"))
     cls.tests.append(getinfos("tool"))
     cls.tests.append(getinfos("2tool"))
     cls.tests.append(getinfos("2yomi"))
     cls.tests.append(getinfos("4yomi"))
     cls.tests.append(getinfos("reimei", True))
     cls.tests.append(getinfos("1reimei"))
Ejemplo n.º 5
0
    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