Code Monkey home page Code Monkey logo

Comments (7)

nateraw avatar nateraw commented on May 24, 2024 1

Worked for me.

image

from lyricsgenius.

johnwmillr avatar johnwmillr commented on May 24, 2024

From a new comment on my blog:

Hi John. I seem to be running into the same error as Elijah. I'm not sure if I'm doing something wrong (I'm quite new to Python and programming in general).

It happens with a few artists (for example, Kacey Musgraves, Kanye West, and Taylor Swift).

Here is my code:
songs_by_artist = api.search_artist('Kacey Musgraves')

I get 4 songs, and then an error:
Searching for songs by Kacey Musgraves...

Song 1: "Apologize (Acoustic Version)"
Song 2: "Are You Sure"
Song 3: "A Spoonful of Sugar (from "Mary Poppins")"
"A Very Kacey Christmas [Tracklist + Album Cover]" does not contain lyrics. Rejecting.
Song 4: "A Willie Nice Christmas"

File "C:\Users\Nick\Anaconda2\envs\Playground36TwentyEighteen\lib\site-packages\lyricsgenius\api.py", line 243, in search_artist
lyrics = self._scrape_song_lyrics_from_url(json_song['url'], remove_section_headers)

File "C:\Users\Nick\Anaconda2\envs\Playground36TwentyEighteen\lib\site-packages\lyricsgenius\api.py", line 112, in scrape_song_lyrics_from_url
lyrics = html.find("div", class
="lyrics").get_text()

AttributeError: 'NoneType' object has no attribute 'get_text'

I thought this error might be due to using an old version of the package (because I don't run into the same error when running the search myself), but I didn't run into any errors when trying earlier versions either (0.5 and 0.2).

I checked my versions and am using Python 3.6.2, IPython 6.1.0, and lyricsgenius 0.6.3.

from lyricsgenius.

NickReiher avatar NickReiher commented on May 24, 2024

Hey. It's Nick, who reported the bug on your blog.

I took a look at the code and think I found the issue. There are times that a song is in json_search with a URL, but the URL is not valid. For example: https://genius.com/Taylor-swift-acting-like-a-boy-lyrics . The method _scrape_song_lyrics_from_url() then tries to do a .get_text() on class lyrics of the html, but that doesn't exist.

I think the solution is to add another check somewhere in the process to see if the URL is valid and the lyrics exist. I found a quick solution that checks if the lyrics class exists on the URL -- the error doesn't happen and most of the songs are loaded like normal, and for URLs that don't exist the lyrics are a string that is just a space: " ". Of course this isn't ideal and there are better ways to solve it.

If it's alright with you, I'd like to try to solve the issue myself in the next few days. This is my first time working on a project on GitHub and on an open source project, so I think the experience of going through it could help me learn quite a bit of how these things work.

from lyricsgenius.

johnwmillr avatar johnwmillr commented on May 24, 2024

Great catch! Go for it. Fork the repository then open a pull request back to mine when you’ve come up with a fix.

from lyricsgenius.

nateraw avatar nateraw commented on May 24, 2024

Should this issue be closed? Is this solved?

from lyricsgenius.

johnwmillr avatar johnwmillr commented on May 24, 2024

I think it likely can be closed, but I'm not sure if the problem has been fixed for @NickVance. I was unfortunately never able to recreate the issue he described above.

Do you mind helping out to check if you have the same error he had? Try this command:

songs_by_artist = api.search_artist('Kacey Musgraves', max_songs=8)

If you have the same bug he had, you'll get an error after the 4th song. If you are able to run the code without an error, I'd say we can merge #52 and close this issue.

from lyricsgenius.

johnwmillr avatar johnwmillr commented on May 24, 2024

Wonderful! Thanks for giving it a try. I'll merge #52 (after fixing the conflicts) and close the issue.

from lyricsgenius.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.