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

Fixed multiple artists in album not loading up #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mopidy_ytmusic/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,9 @@ def albumToTracks(self, album, bId):
):
songartists = artists
else:
songartists = [Artist(name=song["artists"])]
songartists = []
for artist in song["artists"]:
Copy link
Contributor

@kmac kmac May 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know if this is always a list here?

I was going to submit a pull request which checked if it's a list and falls back to the existing else, like this:

                elif type(song["artists"]) is list:
                    # handle case where we have a list of dictionaries like:
                    #   [{'name':..., 'id':...}, ]
                    songartists = [Artist(name=sa["name"])
                                   for sa in song["artists"]]
                else:
                    songartists = [Artist(name=song["artists"])]

but I am new to using this project, so I'm not sure if we need the extra check or not.

Edit: fixed my code to add multiple Artist instances, like yours. Basically I'm just wondering if we need to check it it's a list.

songartists.append(Artist(name=artist['name'], uri=f"ytmusic:artist:{artist['id']}"))
self.TRACKS[song["videoId"]] = Track(
uri=f"ytmusic:track:{song['videoId']}",
name=song["title"],
Expand Down