def diff(self, beatmap_id: str, mods: None): if mods == None: self.map_osu(beatmap_id) Map = oppadc.OsuMap(file_path='map.osu') Stats = Map.getStats() return str(round(Stats.total, 2)) else: self.map_osu(beatmap_id) Map = oppadc.OsuMap(file_path='map.osu') Stats = Map.getStats(mods) return str(round(Stats.total, 2))
def fullpp(self, beatmap_id: str, n300: int, n100: int, n50: int, mods=None): if mods == None: self.map_osu(beatmap_id) Map = oppadc.OsuMap(file_path='map.osu') PP = Map.getPP(n300=n300, n100=n100, n50=n50) print(round(PP.total_pp, 1)) return round(PP.total_pp, 1) else: self.map_osu(beatmap_id) Map = oppadc.OsuMap(file_path='map.osu') PP = Map.getPP(mods, n300=n300, n100=n100, n50=n50) print(round(PP.total_pp, 1)) return round(PP.total_pp, 1)
def perfectpp(self, beatmap_id: str, mods=None): if mods == None: self.map_osu(beatmap_id) Map = oppadc.OsuMap(file_path='map.osu') PP = Map.getPP() print(round(PP.total_pp, 1)) return round(PP.total_pp, 1) else: self.map_osu(beatmap_id) Map = oppadc.OsuMap(file_path='map.osu') PP = Map.getPP(mods) print(round(PP.total_pp, 1)) return round(PP.total_pp, 1)
def pippi(self, beatmap_id: str, n300: int, n100: int, n50: int, miss: int, combo: int, mods=None): if mods == None: self.map_osu(beatmap_id) Map = oppadc.OsuMap(file_path='map.osu') PP = Map.getPP(n300=n300, n100=n100, n50=n50, misses=miss, combo=combo) print(round(PP.total_pp, 1)) return round(PP.total_pp, 1) else: self.map_osu(beatmap_id) Map = oppadc.OsuMap(file_path='map.osu') PP = Map.getPP(mods, n300=n300, n100=n100, n50=n50, misses=miss, combo=combo) print(round(PP.total_pp, 1)) return round(PP.total_pp, 1)
def info_diff_mod(self, beatmap_id: str, mods): self.map_osu(beatmap_id) Map = oppadc.OsuMap(file_path='map.osu') PP = Map.getPP(mods) Stats = Map.getStats() Diff = Map.getDifficulty() return Diff
def ppcal(self, mods, acc, r, mdata): Map = oppadc.OsuMap(raw_str=mdata) PP = Map.getPP(mods, misses=int(r[0]['countmiss']), combo=int(r[0]['maxcombo']), accuracy=float(acc)) return PP
async def calc(self): curMap = oppadc.OsuMap(file_path=self.bm_path) pp = curMap.getPP(self.mods, accuracy=self.acc, misses=self.nmiss, combo=self.combo) return pp.total_pp
def __init__(self, map_id, mods, link_type="id"): """ get stats on map // map api :param map_id: :param mods: mod :param link_type: [id|map|path|url] :return: map data dict, map object with calculated values """ if link_type == "id": link = f"https://osu.ppy.sh/osu/{map_id}" else: link = map_id if link_type == "map": raw_map = link elif link_type == "path": with open(link, "r") as mp: raw_map = mp.read() else: raw_map = requests.get(link).text if raw_map == "": raise BadLink bmp = oppa.OsuMap(raw_str=raw_map) # , auto_parse=True) if not bmp.hitobjects: raise BadMapFile speed = speed_multiplier(mods) map_creator = get_user(bmp.creator)[0] stats = bmp.getStats(mod_int(mods)) diff = CalculateMods(mods) length = bmp.hitobjects[-1].starttime change_list = [i for i in bmp.timingpoints if i.change] bpm_avg = list() bpm_list = list() for j, i in enumerate(change_list): if i.change: if j + 1 == len(change_list): dur = length - i.starttime else: dur = change_list[j + 1].starttime - i.starttime bpm_avg.append((1000 / i.ms_per_beat * 60) * dur) bpm_list.append((1000 / i.ms_per_beat * 60)) self.speed_multiplier = speed self.artist = bmp.artist self.title = bmp.title self.artist_unicode = bmp.artist_unicode self.title_unicode = bmp.title_unicode self.version = bmp.version self.bpm_min = min(bpm_list) * speed self.bpm_max = max(bpm_list) * speed self.total_length = (length - bmp.hitobjects[0].starttime) / 1000. / speed self.max_combo = 0 self.creator = bmp.creator self.creator_id = map_creator["user_id"] self.map_creator = Dict(map_creator) # todo make user object self.base_cs = bmp.cs self.base_ar = bmp.ar self.base_od = bmp.od self.base_hp = bmp.hp self.cs = diff.cs(bmp.cs)[0] self.ar = diff.ar(bmp.ar)[0] self.od = diff.od(bmp.od)[0] self.hp = diff.hp(bmp.hp)[0] self.mode = bmp.mode self.hit_objects = len(bmp.hitobjects) self.count_normal = bmp.amount_circle self.count_slider = bmp.amount_slider self.count_spinner = bmp.amount_spinner bmp.getStats() if link_type == "id": self.approved = 0 self.submit_date = None self.approved_date = None self.last_update = None self.beatmap_id = 0 self.beatmapset_id = 0 self.source = "" self.genre_id = 0 self.language_id = 0 self.file_md5 = "" self.tags = "" self.favourite_count = 0 self.rating = 0.0 self.playcount = 0 self.passcount = 0 self.download_unavailable = False self.audio_unavailable = False mods_applied = mod_int(mods) map_web = OSU_API.get("/get_beatmaps", { "b": map_id, "mods": mods_applied }).json() if not map_web: raise BadId dict_string_to_nums(map_web[0]) for i, j in map_web[0].items(): setattr(self, i, j) self.submit_date = arrow.get(self.submit_date, DATE_FORM) self.approved_date = arrow.get(self.approved_date, DATE_FORM) self.last_update = arrow.get(self.last_update, DATE_FORM) self.download_unavailable = bool(self.download_unavailable) self.audio_unavailable = bool(self.audio_unavailable) try: self.leaderboard = get_leaderboard(map_id) except NoLeaderBoard: self.leaderboard = [] if self.max_combo is None: self.max_combo = bmp.maxCombo() self.aim_stars = stats.aim # not sure if its aim or aim_difficulty self.speed_stars = stats.speed self.total = stats.total self.bpm = sum(bpm_avg) / (length - bmp.hitobjects[0].starttime) * speed self.beatmap = bmp
def fcpp(self, mods, acc, mdata): Map = oppadc.OsuMap(raw_str=mdata) FPP = Map.getPP(mods, accuracy=float(acc)) return FPP
def setBeatmapInformation(self, message, redownload=None): ''' Set the beatmap_id and OppaiMapInfo as an class attribute. Parameters: message* (obj): The message with the associated information *need to be a link redownloa : by default it set to None, so each map get download, if it's set to something the mapset don't get redownloaded Return: Nothing, this function simply sets attributes ''' # Detects if modes where added after the link space = message.find(" ") if space != -1: self.mods = message[space+1:] self.mods = self.mods.upper() space = 1 else: self.mods = None space = 0 # set beatmap_id as an attribute for the whole class index = message.rindex("/") if self.mods != None: self.beatmap_id = message[index+1:-len(self.mods)-space] else : self.beatmap_id = message[index+1:] res = osuApiCall.get_beatmaps(beatmap_id=self.beatmap_id) beatmap = res[0] resMapset= osuApiCall.get_beatmaps(beatmapset_id=beatmap.beatmapset_id) mapsetUnsorted = {} for v in resMapset: mapsetUnsorted[v]=v.difficultyrating self.mapset=list(dict(sorted(mapsetUnsorted.items(),key= lambda x:x[1]))) # Before downloading the mapset we will remove the existing files and then we'll download the mapset if redownload == None: for file in os.listdir('C:/Users/DELL/Desktop/osu-mocha/map_cache/'): os.remove(os.path.join('C:/Users/DELL/Desktop/osu-mocha/map_cache/', file)) url = 'https://nerina.pw/d/' + str(beatmap.beatmapset_id) wget.download(url, 'C:/Users/DELL/Desktop/osu-mocha/map_cache/' + str(beatmap.beatmapset_id) + ".osz") # osz are compressed files, we can basically open them with zip pathFile = "" with ZipFile('C:/Users/DELL/Desktop/osu-mocha/map_cache/' + str(beatmap.beatmapset_id) + '.osz', 'r') as zip: for filename in zip.namelist(): if filename.endswith('.osu') and filename.find(beatmap.version) != -1: zip.extract(filename,'C:/Users/DELL/Desktop/osu-mocha/map_cache/') pathFile = 'C:/Users/DELL/Desktop/osu-mocha/map_cache/' + filename self.oppaiMapInfo = oppadc.OsuMap(file_path=pathFile)