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

when doing api.search_artist, there is no attribute like album and year #187

Closed GhostWnd closed 3 years ago

GhostWnd commented 3 years ago

Describe the bug For the following code:

artist = api.search_artist(query,max_songs=n,sort='popularity') songs = artist.songs for song in songs: print(song.album) print(song.year)

Errors are reported like 'Song' object has no attribute 'album' and 'Song' object has no attribute 'year' Several months before, codes above can run correctly and there were no errors

Expected behavior There should be print of song.album and song.year

To Reproduce Describe the steps required to reproduce the behavior. The core codes have been displayed above

Include the error message associated with the bug.

Version info

allerter commented 3 years ago

You're using version 3.0.0 which doesn't have those attributes (here's the list of Song attributes). If you need those attributes, you should just use the version you were using then. Right now version 3.0 doesn't add album and release_date attributes to the Song object, but they may be present if you use the Song.to_dict() method.

from lyricsgenius import Genius
genius = Genius(GENIUS_ACCESS_TOKEN)
song = genius.search_song("To You", "Andy Shauf", get_full_info=True)
song_dict = song.to_dict()
print(song_dict.keys())