def viewtopscores(musicid: int) -> Response: # We just want to find the latest mix that this song exists in frontend = PopnMusicFrontend(g.data, g.config, g.cache) versions = sorted( [version for (game, version, name) in frontend.all_games()], reverse=True, ) name = None artist = None genre = None difficulties = [0, 0, 0, 0] for version in versions: for omniadd in [0, 10000]: for chart in [0, 1, 2, 3]: details = g.data.local.music.get_song(GameConstants.POPN_MUSIC, version + omniadd, musicid, chart) if details is not None: if name is None: name = details.name if artist is None: artist = details.artist if genre is None: genre = details.genre if difficulties[chart] == 0: difficulties[chart] = details.data.get_int( 'difficulty') if name is None: # Not a real song! abort(404) top_scores = frontend.get_top_scores(musicid) return render_react( f'Top Pop\'n Music Scores for {artist} - {name}', 'popn/topscores.react.js', { 'name': name, 'artist': artist, 'genre': genre, 'difficulties': difficulties, 'players': top_scores['players'], 'topscores': top_scores['topscores'], }, { 'refresh': url_for('popn_pages.listtopscores', musicid=musicid), 'player': url_for('popn_pages.viewplayer', userid=-1), }, )
def listtopscores(musicid: int) -> Dict[str, Any]: frontend = PopnMusicFrontend(g.data, g.config, g.cache) return frontend.get_top_scores(musicid)