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

Genre query early stopping #271

Open orlevit opened 3 months ago

orlevit commented 3 months ago

I am using the snippets in the docs: link to get "Getting songs by tag (genre)":

# this gets the lyrics of all the songs that have the pop tag.
genius = Genius(token)
page = 1
lyrics = []
while page:
    res = genius.tag('pop', page=page)
    for hit in res['hits']:
        song_lyrics = genius.lyrics(song_url=hit['url'])
        lyrics.append(song_lyrics)
    page = res['next_page']

I am running this code with tag : "bachata" and noticed that one page is returning 19 results instead of 20: image

In the source code : "res['next_page']" is None if the length of the hits not equals 20... Is it a bug?