[GH-ISSUE #257] Album tracks info (in get_album) returns "None" for artists and album #201

Closed
opened 2026-02-27 22:08:34 +03:00 by kerem · 2 comments
Owner

Originally created by @SubjunctiveQuaver on GitHub (Feb 1, 2022).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/257

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.

Originally created by @SubjunctiveQuaver on GitHub (Feb 1, 2022). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/257 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](https://user-images.githubusercontent.com/49895442/151922037-e8a58a03-eabe-4143-a120-d2665b4e5c6a.png) Minimal working example: ```python 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.
kerem closed this issue 2026-02-27 22:08:34 +03:00
Author
Owner

@sigma67 commented on GitHub (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

<!-- gh-comment-id:1026740017 --> @sigma67 commented on GitHub (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
Author
Owner

@natumbri commented on GitHub (May 28, 2022):

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?

<!-- gh-comment-id:1140244777 --> @natumbri commented on GitHub (May 28, 2022): 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 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#201
No description provided.