[GH-ISSUE #387] Params key not in get_artist #303

Closed
opened 2026-02-27 22:59:59 +03:00 by kerem · 1 comment
Owner

Originally created by @kalebbroo on GitHub (Apr 29, 2023).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/387

Describe the bug
I am trying to return a list of all the albums from an artist using get_artist_albums. I cannot figure out how to get the perams key. I am only just learning how to code so this is most likely just a dumb mistake on my part. The api docs says to get params use get_artist but I am not able to return that key.

Error searching for artist albums: 'params'
Traceback (most recent call last):
File "C:\Users\kaleb\Desktop\projects\search_youtube\embed.py", line 46, in search_albums
artist_albums_params = artist_data['albums']['params']
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'params'

To Reproduce
I plan to make this a discord bot, I search for an artist I have been using "will smith" and "loona" for testing. The code will return an key error.

Here is my code:
async def search_albums(ctx, artist_name: str):
artist_name = artist_name.title()
print(f"Searching for albums by artist: {artist_name}")

ytmusic = YTMusic()

try:
    search_result = ytmusic.search(artist_name, filter='artists', limit=1)
    print(f"Search Result: {search_result}")

    if not search_result:
        await ctx.send(f"No artist found for '{artist_name}'")
        return

    artist_id = search_result[0]['browseId']
    artist_data = ytmusic.get_artist(artist_id)
    print(f"Artist Data First: {artist_data}")
    artist_name = artist_data.get('name')
    artist_channel_id = artist_data.get('channelId')
    artist_data = ytmusic.get_artist(artist_channel_id)
    print(f"Artist Data: {artist_data}")
    print(f"Channel ID: {artist_channel_id}")
    artist_albums_params = artist_data['albums']['params']
    album_data = ytmusic.get_artist_albums(artist_channel_id, artist_albums_params)

Additional context
If this is something I am doing wrong in my code just let me know. I have been trying to figure this out all day :(

Originally created by @kalebbroo on GitHub (Apr 29, 2023). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/387 **Describe the bug** I am trying to return a list of all the albums from an artist using get_artist_albums. I cannot figure out how to get the perams key. I am only just learning how to code so this is most likely just a dumb mistake on my part. The api docs says to get params use get_artist but I am not able to return that key. Error searching for artist albums: 'params' Traceback (most recent call last): File "C:\Users\kaleb\Desktop\projects\search_youtube\embed.py", line 46, in search_albums artist_albums_params = artist_data['albums']['params'] ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ KeyError: 'params' **To Reproduce** I plan to make this a discord bot, I search for an artist I have been using "will smith" and "loona" for testing. The code will return an key error. Here is my code: async def search_albums(ctx, artist_name: str): artist_name = artist_name.title() print(f"Searching for albums by artist: {artist_name}") ytmusic = YTMusic() try: search_result = ytmusic.search(artist_name, filter='artists', limit=1) print(f"Search Result: {search_result}") if not search_result: await ctx.send(f"No artist found for '{artist_name}'") return artist_id = search_result[0]['browseId'] artist_data = ytmusic.get_artist(artist_id) print(f"Artist Data First: {artist_data}") artist_name = artist_data.get('name') artist_channel_id = artist_data.get('channelId') artist_data = ytmusic.get_artist(artist_channel_id) print(f"Artist Data: {artist_data}") print(f"Channel ID: {artist_channel_id}") artist_albums_params = artist_data['albums']['params'] album_data = ytmusic.get_artist_albums(artist_channel_id, artist_albums_params) **Additional context** If this is something I am doing wrong in my code just let me know. I have been trying to figure this out all day :(
kerem closed this issue 2026-02-27 23:00:03 +03:00
Author
Owner

@sigma67 commented on GitHub (May 1, 2023):

Hi, this doesn't work for all artists. Notably when there is no "More" button on the artist's page next to the albums, there won't be any params.

For example, for Will Smith, singles would work but albums would not:

image

<!-- gh-comment-id:1529470114 --> @sigma67 commented on GitHub (May 1, 2023): Hi, this doesn't work for all artists. Notably when there is no "More" button on the artist's page next to the albums, there won't be any params. For example, for [Will Smith](https://music.youtube.com/channel/UCdHscQsCBWSfcW50NjdJWkA), singles would work but albums would not: ![image](https://user-images.githubusercontent.com/16363825/235438053-20f664c6-cfe4-4174-8f68-2b87e5c71276.png)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#303
No description provided.