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

Error message #77

Closed
Chris31070 opened this issue Dec 8, 2018 · 14 comments
Closed

Error message #77

Chris31070 opened this issue Dec 8, 2018 · 14 comments

Comments

@Chris31070
Copy link

Chris31070 commented Dec 8, 2018

Hi, I get an error message while using your code:

import lyricsgenius as genius
api = genius.Genius('----my api code ---')
artist = api.search_artist('Andy Shauf', max_songs=3)

Error message:

Traceback (most recent call last):
File "C:/Users/Chris/AppData/Local/Programs/Python/Python37-32/top2000/181208 top2000.py", line 3, in
artist = api.search_artist('Andy Shauf', max_songs=3)
File "C:\Users\Chris\AppData\Local\Programs\Python\Python37-32\lib\site-packages\lyricsgenius\api.py", line 283, in search_artist
found_name = artist_info['artist']['name']
TypeError: 'NoneType' object is not subscriptable

Can you help me with this?
Many thanks!

@Chris31070
Copy link
Author

I copied the wrong api code, it all works fine!

@johnwmillr
Copy link
Owner

Great! Let me know if you run into any other issues.

@Chris31070
Copy link
Author

Chris31070 commented Dec 21, 2018 via email

@johnwmillr
Copy link
Owner

Hi Chris,

If I understand you correctly, something like this might work for you:

# songPairs is a list of song title and artist name pairs
# (e.g. [["I Will", "The Beatles"], ["Begin Again", "Andy Shauf"]])
for pair in songPairs:
  song = api.search_song(pair[0], pair[1])
  if song:
    savename = "Lyrics_{A}_{T}".format(song.title, song.artist)
    song.save_lyrics(savename, forma_="txt")

Does that seem like what you want? Let me know if it works for you.
John

@Chris31070
Copy link
Author

Many thanks Jonn, let me check this out! So far I used the standard 10 hits result and took the first URL.

@mrpandastic
Copy link

Hi Jonn,

I'm quite new to Python and trying to retrieve lyrics from genius.com with your package. Unfortunately, I still keep on receiving the error:

TypeError: 'NoneType' object is not subscriptable

I used the same code as Chris31070 previously posted but it's not working. Can you help me out? Thanks a lot!

@johnwmillr
Copy link
Owner

Hi @mrpandastic, what version of the package are you using? If it's not the latest version (1.6.0), try updating with pip:

pip install -U lyricsgenius

@mrpandastic
Copy link

Hi @mrpandastic, what version of the package are you using? If it's not the latest version (1.6.0), try updating with pip:

pip install -U lyricsgenius

yes, 1.6.0 is installed

@johnwmillr
Copy link
Owner

johnwmillr commented Aug 7, 2019

I don't get the same error when executing the code. What happens if you try in Python:

genius.get_artist(29472)

Do you get a lot of data back? Did you properly set up your API key?

@mrpandastic
Copy link

mrpandastic commented Aug 7, 2019

This is what's in my Jupyter Notebook:

import lyricsgenius

genius = lyricsgenius.Genius("--mykey--")
artist = genius.search_artist("Eminem", max_songs=3, sort="title")`

and this is the error I get:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-47-08dc5616b4a3> in <module>
      2 
      3 genius = lyricsgenius.Genius("--mykey--") 
----> 4 artist = genius.search_artist("Eminem", max_songs=3, sort="title")

~\AppData\Roaming\Python\Python37\site-packages\lyricsgenius\api.py in search_artist(self, artist_name, max_songs, sort, per_page, get_full_info, allow_name_change, artist_id)
    294 
    295         artist_info = self.get_artist(artist_id)
--> 296         found_name = artist_info['artist']['name']
    297         if found_name != artist_name and allow_name_change:
    298             if self.verbose:

TypeError: 'NoneType' object is not subscriptable

@johnwmillr
Copy link
Owner

What happens when you try this?

import lyricsgenius
genius = lyricsgenius.Genius("--mykey--")
genius.get_artist(29472)

Do you get any data in response?

@mrpandastic
Copy link

What happens when you try this?

import lyricsgenius
genius = lyricsgenius.Genius("--mykey--")
genius.get_artist(29472)

Do you get any data in response?

No data but also no TypeError. It just says None.

import lyricsgenius genius = lyricsgenius.Genius("--mykey--") artist = genius.get_artist(29472) print(artist)

@mrpandastic
Copy link

What happens when you try this?

import lyricsgenius
genius = lyricsgenius.Genius("--mykey--")
genius.get_artist(29472)

Do you get any data in response?

No data but also no TypeError. It just says None.

import lyricsgenius genius = lyricsgenius.Genius("--mykey--") artist = genius.get_artist(29472) print(artist)

Oh it works now. Looks like I'm an idiot who mixed up the client secret and client access token. omg
Anyway, sorry for bothering you with my questions and thank you so much for your help. Really appreciate it!

@johnwmillr
Copy link
Owner

johnwmillr commented Aug 9, 2019 via email

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

3 participants