Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError when searching for albums that do not have full release date listed #195

Closed
BrodyMcNutt opened this issue Mar 17, 2021 · 1 comment

Comments

@BrodyMcNutt
Copy link

Describe the bug
When using the search_album function, an attribute error occurs for albums that do not have the full release data listed on their Genius page. For example, the page for Joey Purp's album iiiDrops says "Released 2016", while most pages give an exact date.

Expected behavior
I expect the function to retrieve the album information for the given album and provide either a null value or just the year for the release date if the exact release date is not known.

To Reproduce
Search for any album that does not have a full release date. Using the same example given before:

import lyricsgenius
token = 'YOURTOKENHERE'
genius = lyricsgenius.Genius(token)
album = genius.search_album("iiiDrops", "Joey Purp")

Output:

Searching for "iiiDrops" by Joey Purp...

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-58-0284c1ae1410> in <module>
----> 1 album = genius.search_album("iiiDrops", "Joey Purp")

~/opt/anaconda3/envs/DataMining/lib/python3.8/site-packages/lyricsgenius/genius.py in search_album(self, name, artist, album_id, get_full_info, text_format)
    354             album_info.update(new_info)
    355 
--> 356         return Album(self, album_info, tracks)
    357 
    358     def search_song(self, title=None, artist="", song_id=None,

~/opt/anaconda3/envs/DataMining/lib/python3.8/site-packages/lyricsgenius/types/album.py in __init__(self, client, json_dict, tracks)
     15         self.artist = Artist(client, body['artist'])
     16         self.tracks = tracks
---> 17         self.release_date_components = convert_to_datetime(
     18             body['release_date_components']
     19         )

~/opt/anaconda3/envs/DataMining/lib/python3.8/site-packages/lyricsgenius/utils.py in convert_to_datetime(f)
     55         f = date
     56 
---> 57     if f.count('-') == 2:
     58         date_format = "%Y-%m-%d"
     59     elif f.count('-') == 1:

AttributeError: 'int' object has no attribute 'count'

Include the error message associated with the bug.

Version info

  • Package version 3.0.0
  • OS: macOS 10.15 (Catalina)

Additional context
Based on the error message, I figured the issue likely had something to do with the date format. After checking manually, all of the albums I tried that produced this error had a release date like the example given here on their respective Genius pages, but it is possible that there may be other problematic date formats as well. This is the only problem I have had using the API so far, thank you for the great work you all have done on this!

@BrodyMcNutt
Copy link
Author

My mistake, I now see this bug has been brought up before and a fix was suggested in this pull request, but has not been merged yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant