sigma67 / ytmusicapi

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

Add a get_artist_songs just like get_artist_albums #596

Closed kevinmarquesp closed 4 months ago

kevinmarquesp commented 4 months ago

Is your feature request related to a problem? Please describe. I would be nice to have a get_artist_songs() just like the get_artist_albums(), but without the params because the get_artist() function returns doesn't have a params key in the songs field.

Describe the solution you'd like For an example of usage that I expect:

from ytmusicapi import YTMusic

ytm = YTMusic()

artist = ytm.get_artist("UCu3D7Xd6Wxt4f1PYokvZVVA")
browse_id = artist["songs"]["browseId"]

songs = ytm.get_artist_songs(browse_id, limit=None)

# Then I expect to get an list of a bunch of song dicts.
print(songs)

Describe alternatives you've considered I tried to follow the docs, there was said that I could do that with the get_artist_albums() function, but it didn't work because of the params field that the songs doesn't have, unlike the singles, videos and albums. Maybe fixing that issue would be better, but I still prefer a separate function for them all.

Additional context I was trying to create a CLI application that will allow users to fetch JSON data from the Youtube Music API and integrate it with yt-dlp with jq, or something like that, and the songs subcommand isn't working in anyway.

sigma67 commented 4 months ago

If you read the docs carefully, you'll find that the songs key contains a browseId, which is usable with get_playlist.

https://ytmusicapi.readthedocs.io/en/latest/reference.html#ytmusicapi.YTMusic.get_artist