sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.76k stars 209 forks source link

get_artist KeyError: 'playButton' #165

Closed chaos87 closed 3 years ago

chaos87 commented 3 years ago

Hi,

I'm using 0.14.1 and when I do (unauthenticated)

from ytmusicapi import YTMusic
ytmusic = YTMusic()
ytmusic.get_artist('UCbCrm_eTkVVRbwnR0cj-phQ')

I get

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-17-842c3ff40966> in <module>()
     16 #     print(fuzz.ratio(query.lower(), artist))
     17 # df_search
---> 18 ytmusic.get_artist('UCbCrm_eTkVVRbwnR0cj-phQ')
     19 # wFMCbgy1S3A

2 frames
/usr/local/lib/python3.6/dist-packages/ytmusicapi/mixins/browsing.py in get_artist(self, channelId)
    279         artist['channelId'] = subscription_button['channelId']
    280         artist['shuffleId'] = nav(header,
--> 281                                   ['playButton', 'buttonRenderer'] + NAVIGATION_WATCH_PLAYLIST_ID)
    282         artist['radioId'] = nav(header, ['startRadioButton', 'buttonRenderer']
    283                                 + NAVIGATION_WATCH_PLAYLIST_ID)

/usr/local/lib/python3.6/dist-packages/ytmusicapi/parsers/utils.py in nav(root, items, none_if_absent)
    208             return None
    209         else:
--> 210             raise err
    211 
    212 

/usr/local/lib/python3.6/dist-packages/ytmusicapi/parsers/utils.py in nav(root, items, none_if_absent)
    202     try:
    203         for k in items:
--> 204             root = root[k]
    205         return root
    206     except Exception as err:

KeyError: 'playButton'
sigma67 commented 3 years ago

Good find, seems not every artist has shuffle/radio mixes

bohrasankalp commented 3 years ago

The issue still persists.

I ended up with

Traceback (most recent call last):
  File "/home/sony/Desktop/yt/lib/python3.6/site-packages/ytmusicapi/parsers/utils.py", line 210, in nav
    raise err
  File "/home/sony/Desktop/yt/lib/python3.6/site-packages/ytmusicapi/parsers/utils.py", line 204, in nav
    root = root[k]
KeyError: 'playButton'
sigma67 commented 3 years ago

Which artist? The artist mentioned above should be fine.

Did you use the latest Github master with pip install git+https://github.com/sigma67/ytmusicapi?

bohrasankalp commented 3 years ago

Try with this. artistId = "UCpZQNFrsFaC9bQgwcruLcwg". I have installed the latest. Even run this command before searching here.

sigma67 commented 3 years ago

Sorry but it should work fine if you are on abbc13f. I get the following results:

{
  "description": null,
  "views": null,
  "name": "Chitra Singh",
  "channelId": "UCpZQNFrsFaC9bQgwcruLcwg",
  "shuffleId": null,
  "radioId": null,
  "subscribers": "11.1K",
  "subscribed": false,
  "thumbnails": [],
  "songs": {
    "browseId": "VLPLM5K8amubQnA3Cljlf7a8xV8jEuUBjyLk",
    "results": [],
    "params": "6gPeAUNxTUJDb01CQ25RQUFHV..."
  }
}
bohrasankalp commented 3 years ago

Then pip install git+https://github.com/sigma67/ytmusicapi doesn't update me to the latest.

sigma67 commented 3 years ago

Try adding -U switch, since version number has not changed yet.

bohrasankalp commented 3 years ago

No, it doesn't work. There should be some other workaround.

sigma67 commented 3 years ago

As I said, it works fine for me. Wait until the release of 0.14.2 or submit a PR if you can identify something else that's wrong

chaos87 commented 3 years ago

Cool it works for me with your latest commit. Thanks