Exemple #1
0
def get_lyrics(interpret):
    if not os.path.exists(f"Lyrics_{interpret}.json"):
        with open("token", "r") as f:
            token = f.read().strip()

        genius = Genius(token)
        artist = genius.search_artist(interpret)
        artist.save_lyrics()
    with open(f"Lyrics_{interpret}.json", "r") as f:
        lyrics = json.loads(f.read())
    return lyrics
def get_top_songs_for_artist(genius: lyricsgenius.Genius,
                             artist: str,
                             max_songs: int = None) -> List[dict]:
    """Searches Genius for the top songs for a given artist.

    Args:
        genius (lyricsgenius.Genius): LyricsGenius object to use for query.
        artist (str): Name of artist
        max_songs (int, optional): Maximum number of songs to return.

    Returns:
        List[dict]: List of songs or empty if no results.
    """
    artist_obj = genius.search_artist(artist,
                                      max_songs=max_songs,
                                      sort='popularity')

    if artist_obj:
        return [song.to_dict() for song in artist_obj.songs]
    else:
        return []
Exemple #3
0
def get_popularity_songs(artist_name: str, max_songs: int, sort="popularity"):
    genius = Genius(os.environ["TOKEN"])
    artist = genius.search_artist(artist_name, max_songs=max_songs, sort=sort)
    return artist.songs
Exemple #4
0
def get_popularity_songs(artist_name: str, max_songs: int, sort="popularity"):
    genius = Genius("WLSp00664-lpegmyI7i4KYmZ5UA_yYf55lNo7auQ6PuBEw3ziIvOkLL8ABZqeNl7")
    artist = genius.search_artist(artist_name, max_songs=max_songs, sort=sort)
    return artist.songs