johnwmillr / LyricsGenius

Download song lyrics and metadata from Genius.com 🎶🎤
http://www.johnwmillr.com/scraping-genius-lyrics/
MIT License
878 stars 159 forks source link

how to get the genre of a song? #255

Closed Mohammad9760 closed 11 months ago

Mohammad9760 commented 1 year ago

https://lyricsgenius.readthedocs.io/en/master/reference/types.html?highlight=song#song there's no attribute for knowing the genre of the song. I want to know if there's a way I can extract genre information about a song. thanks!

allerter commented 1 year ago

AFAIK, there is no way to get the genre of a song.

allerter commented 1 year ago

You can get the genres set for a song from the tags key if you get the song info from their WebAPI:

genius = lyricsgenius.PublicAPI()

song = genius.song(1)["song"]
for tag in song["tags"]:
    print(tag["name"], sep=", ")

There is a chance this might raise a HTTP 403 error which is referenced in #220