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

Album tracks info (in get_album) returns "None" for artists and album #257

Closed
SubjunctiveQuaver opened this issue Feb 1, 2022 · 2 comments

Comments

@SubjunctiveQuaver
Copy link

See the image below for an example where the album chosen was Reputation by Taylor Swift (browse ID: MPREb_BdDqjcHkOwb) with the track being "...Ready For It?":

image

Minimal working example:

from ytmusicapi import YTMusic

ytmusic = YTMusic()

print(ytmusic.get_album("MPREb_BdDqjcHkOwb")["tracks"][0])

I would expect it to contain "Taylor Swift" for the artist and "Reputation" for the album.

@sigma67
Copy link
Owner

sigma67 commented Feb 1, 2022

The album details are on the top level in title and artists keys, not in the individual tracks in the tracks key. I agree it would be more intuitive to include it with each track as well instead of putting None, it's just a limitation of how the parsing works currently

@natumbri
Copy link
Contributor

Hi @sigma67 - I know this is closed, but just wondering if instead of returning album as a str, have you considered returning it as a dict:

"album": {
   "name": album title
   "id": album browseId
}

Just means if the track gets separated from the album, it is easy to get it back again.

This would be consistent with how YTMusic.search returns song, YTMusic.get_home returns song quick pick, YTMusic.get_song_related returns You might also like items, YTMusic.get_watch_playlist and YTMusic.get_playlist return tracks.

The only other track/song where album is returned as a str is songs in YTMusic.get_artist - but that might be because for that result, there is no way to easily know the browseId for the album. I guess you'd have to find it in the albums returned by YTMusic.get_artist, by matching the name?

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