Comments (7)
Worked for me.
from lyricsgenius.
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.
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.
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.
Should this issue be closed? Is this solved?
from lyricsgenius.
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.
Wonderful! Thanks for giving it a try. I'll merge #52 (after fixing the conflicts) and close the issue.
from lyricsgenius.
Related Issues (20)
- Lyrics appear to contain a bit of garbage data? HOT 4
- Random Spotify Playlists being Generated HOT 4
- Related Songs showing up in Lyrics HOT 2
- Song search incorrect result
- add per_page parameter to song_annotations
- Get random songs from artist
- Is this library abandoned completely? HOT 5
- All download/progress lost, when crashing while running the genius.search_artist()-Function. HOT 1
- Feature request: add a path option to the genius.save_lyrics()-function HOT 2
- Request timed out during API call for songs of an artist
- Doc clarification search_artist vs artist_songs HOT 1
- Lyrics returned is buggy and includes ads? HOT 4
- how to get the genre of a song? HOT 2
- Reduce Verbosity HOT 1
- Add option to get metadata of desired track HOT 9
- Doesn't return any matching songs HOT 2
- Regex for excluded_terms HOT 1
- Enforce rate limiting HOT 1
- R.E.M. returns Changing artist name to 'Don Toliver' HOT 2
- Lyrics have unwanted data returned with them HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lyricsgenius.