johnwmillr / LyricsGenius

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

Get Genre of Song #176

Closed ManuelBanza closed 3 years ago

ManuelBanza commented 3 years ago

Hi,

Is there anyway to get the genre of a song? I look in the documentation and all I could find related to genre was charts.

Thanks

allerter commented 3 years ago

Hi. Genius doesn't provide genres (or tags as Genius likes to call them) through their official API. However, you can get them through the public/user API. Here's how you can do it:

from lyricsgenius import PublicAPI
song_id = 1  # the song you want tags for
public_api = PublicAPI()
song = public_api.song(song_id)['song']
print(song['tags'])

Note: You must be using v3.0 for this to work. Warning: Personally, I haven't had any problems so far using the user/web API, but here's what one of the staff at Genius said about it:

Using the web API for non-browser based requests is not supported, and people found to be misusing it to gain information not provided by our public API [developers API] may be banned at any time with no warning."

johnwmillr commented 3 years ago

@Allerter, it is for this reason that I'd like to minimize use of the user/web API going forward, prioritizing the token-authorized API whenever possible.

allerter commented 3 years ago

@johnwmillr I agree with you, but it's apparent that Genius has abandoned the developers API for years now and they have no intention of moving the functionality from the web API to the developers API. They abandoned it so early that even for something as simple as getting the genres of a song we have to resort to the web API.