Exemple #1
0
 def __format_iidx_song(
     self,
     version: int,
     songid: int,
     songchart: int,
     name: Optional[str],
     artist: Optional[str],
     genre: Optional[str],
     data: Dict[str, Any],
 ) -> Song:
     return Song(
         game=GameConstants.IIDX,
         version=version,
         songid=songid,
         songchart=songchart,
         name=name,
         artist=artist,
         genre=genre,
         data={
             'bpm_min': int(data['bpm_min']),
             'bpm_max': int(data['bpm_max']),
             'notecount': int(data['notecount']),
             'difficulty': int(data['difficulty']),
         },
     )
Exemple #2
0
 def __format_museca_song(
     self,
     version: int,
     songid: int,
     songchart: int,
     name: Optional[str],
     artist: Optional[str],
     genre: Optional[str],
     data: Dict[str, Any],
 ) -> Song:
     return Song(
         game=GameConstants.MUSECA,
         version=version,
         songid=songid,
         songchart=songchart,
         name=name,
         artist=artist,
         genre=genre,
         data={
             'bpm_min': int(data['bpm_min']),
             'bpm_max': int(data['bpm_max']),
             'limited': int(data['limited']),
             'difficulty': int(data['difficulty']),
         },
     )
Exemple #3
0
 def __format_ddr_song(
     self,
     version: int,
     songid: int,
     songchart: int,
     name: Optional[str],
     artist: Optional[str],
     genre: Optional[str],
     data: Dict[str, Any],
 ) -> Song:
     return Song(
         game=GameConstants.DDR,
         version=version,
         songid=songid,
         songchart=songchart,
         name=name,
         artist=artist,
         genre=genre,
         data={
             'groove': {
                 'air': int(data['groove']['air']),
                 'chaos': int(data['groove']['chaos']),
                 'freeze': int(data['groove']['freeze']),
                 'stream': int(data['groove']['stream']),
                 'voltage': int(data['groove']['voltage']),
             },
             'bpm_min': int(data['bpm_min']),
             'bpm_max': int(data['bpm_max']),
             'category': int(data['category']),
             'difficulty': int(data['difficulty']),
             'edit_id': int(data['editid']),
         },
     )
Exemple #4
0
    def get_song(
        self,
        game: str,
        version: int,
        songid: int,
        songchart: int,
    ) -> Optional[Song]:
        """
        Given a game/version/songid/chart, look up the name, artist and genre of that song.

        Parameters:
            game - String representing a game series.
            version - Integer representing which version of the game.
            songid - Integer representing the ID (from the game) for this song.
            songchart - Integer representing the chart for this song.

        Returns:
            A Song object representing the song details
        """
        sql = (
            "SELECT music.name AS name, music.artist AS artist, music.genre AS genre, music.data AS data "
            +
            "FROM music WHERE music.game = :game AND music.version = :version AND "
            + "music.songid = :songid AND music.chart = :songchart")
        cursor = self.execute(
            sql, {
                'game': game,
                'version': version,
                'songid': songid,
                'songchart': songchart
            })
        if cursor.rowcount != 1:
            # music doesn't exist
            return None
        result = cursor.fetchone()
        return Song(
            game,
            version,
            songid,
            songchart,
            result['name'],
            result['artist'],
            result['genre'],
            self.deserialize(result['data']),
        )
Exemple #5
0
    def get_all_versions_of_song(
        self,
        game: str,
        version: int,
        songid: int,
        songchart: int,
        interested_versions: Optional[List[int]] = None,
    ) -> List[Song]:
        """
        Given a game/version/songid/chart, look up all versions of that song across all game versions.

        Parameters:
            game - String representing a game series.
            version - Integer representing which version of the game.
            songid - Integer representing the ID (from the game) for this song.
            songchart - Integer representing the chart for this song.

        Returns:
            A list of Song objects representing all song versions.
        """
        musicid = self.__get_musicid(game, version, songid, songchart)
        sql = (
            "SELECT version, songid, chart, name, artist, genre, data FROM music "
            "WHERE music.id = :musicid")
        if interested_versions is not None:
            sql += " AND music.version in ({})".format(",".join(
                str(int(v)) for v in interested_versions))
        cursor = self.execute(sql, {'musicid': musicid})
        all_songs = []
        for result in cursor.fetchall():
            all_songs.append(
                Song(
                    game,
                    result['version'],
                    result['songid'],
                    result['chart'],
                    result['name'],
                    result['artist'],
                    result['genre'],
                    self.deserialize(result['data']),
                ))
        return all_songs
Exemple #6
0
    def get_all_songs(
        self,
        game: str,
        version: Optional[int] = None,
    ) -> List[Song]:
        """
        Given a game and a version, look up all song/chart combos associated with that game.

        Parameters:
            game - String representing a game series.
            version - Integer representing which version of the game.

        Returns:
            A list of Song objects detailing the song information for each song.
        """
        sql = (
            "SELECT version, songid, chart, name, artist, genre, data FROM music "
            "WHERE music.game = :game")
        params: Dict[str, Any] = {'game': game}
        if version is not None:
            sql += " AND music.version = :version"
            params['version'] = version
        else:
            sql += " ORDER BY music.version DESC"
        cursor = self.execute(sql, params)

        all_songs = []
        for result in cursor.fetchall():
            all_songs.append(
                Song(
                    game,
                    result['version'],
                    result['songid'],
                    result['chart'],
                    result['name'],
                    result['artist'],
                    result['genre'],
                    self.deserialize(result['data']),
                ))

        return all_songs
Exemple #7
0
 def __format_popn_song(
     self,
     version: int,
     songid: int,
     songchart: int,
     name: Optional[str],
     artist: Optional[str],
     genre: Optional[str],
     data: Dict[str, Any],
 ) -> Song:
     return Song(
         game=GameConstants.POPN_MUSIC,
         version=version,
         songid=songid,
         songchart=songchart,
         name=name,
         artist=artist,
         genre=genre,
         data={
             'difficulty': int(data['difficulty']),
             'category': str(data['category']),
         },
     )
Exemple #8
0
 def __format_reflec_song(
     self,
     version: int,
     songid: int,
     songchart: int,
     name: Optional[str],
     artist: Optional[str],
     genre: Optional[str],
     data: Dict[str, Any],
 ) -> Song:
     return Song(
         game=GameConstants.REFLEC_BEAT,
         version=version,
         songid=songid,
         songchart=songchart,
         name=name,
         artist=artist,
         genre=genre,
         data={
             'difficulty': int(data['difficulty']),
             'folder': int(data['category']),
             'chart_id': str(data['musicid']),
         },
     )