music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.21k stars 44 forks source link

Can not play Apple Music Playlist #2375

Closed smartmatic closed 2 weeks ago

smartmatic commented 1 month ago

What version of Music Assistant has the issue?

2.1.0b1

What version of the Home Assistant Integration have you got installed?

2024.5.1

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

Browsing Apple Music Playlists is possible but i can not open them or play them

How to reproduce

Connect to Apple Music Browse Playlists Try to open a Playlist

Music Providers

Apple Music Spotify

Player Providers

Home Assistant

Full log output

MA_Apple_MusicPlaylist.txt

Additional information

No response

What version of Home Assistant Core are your running

2024.5.5

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

OzGav commented 1 month ago

@MarvinSchenkel

MarvinSchenkel commented 1 month ago

Can you please provide the apple music link (from music.apple.com) to the playlists that are not working? I think there's something wrong with personal playlist vs. Apple music playlist.

smartmatic commented 1 month ago

Here are some examples from my personal playlists:

https://music.apple.com/library/playlist/p.0vPsVqYNbM https://music.apple.com/library/playlist/p.aRbhERJABW https://music.apple.com/library/playlist/p.xYv6I46vaBq

This is a apple playlist wich can i can also not play (added to my favourite playlists) https://music.apple.com/library/playlist/p.EmvkSzpB03M

MarvinSchenkel commented 1 month ago

Here are some examples from my personal playlists:

https://music.apple.com/library/playlist/p.0vPsVqYNbM https://music.apple.com/library/playlist/p.aRbhERJABW https://music.apple.com/library/playlist/p.xYv6I46vaBq

This is a apple playlist wich can i can also not play (added to my favourite playlists) https://music.apple.com/library/playlist/p.EmvkSzpB03M

Could you make those playlists public, so I can see them?

smartmatic commented 1 month ago

You should see them on my Apple Music profile "@ubur"

OzGav commented 1 month ago

That is going to a GitHub profile?

smartmatic commented 1 month ago

That is going to a GitHub profile?

It's my Apple Music Profile Name but it has nothing to do with that Github user. It's an another person :-)

chasut commented 1 month ago

I am having a similar issue, but perhaps presents different. I can open the playlist, but will recieve an error "tracks not found". This happens with the apple playlists, but not always. i.e. some work and some don't. Oddly the only ones that I get the playlist picture don't work. The ones that do work none get the playlist picture. logs below.

2024-05-29 16:53:31.829 ERROR (MainThread) [music_assistant] Error doing task: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 98, in add_item_to_library await self.mass.metadata.get_metadata(item) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/metadata.py", line 334, in get_metadata await self.get_playlist_metadata(item) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/metadata.py", line 265, in get_playlist_metadata playlist_items = await self.mass.music.playlists.tracks(playlist.item_id, playlist.provider) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/playlists.py", line 62, in tracks tracks = await self._get_provider_playlist_tracks( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/playlists.py", line 379, in _get_provider_playlist_tracks for item in await provider.get_playlist_tracks(item_id, offset=offset, limit=limit): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/apple_music/__init__.py", line 253, in get_playlist_tracks for track in await self._get_all_items(endpoint, include="artists,catalog"): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/apple_music/__init__.py", line 534, in _get_all_items result = await self._get_data(endpoint, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/helpers/throttle_retry.py", line 72, in wrapper return await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/apple_music/__init__.py", line 556, in _get_data raise MediaNotFoundError(f"{endpoint} not found") music_assistant.common.models.errors.MediaNotFoundError: me/library/playlists/pl.c74ebd652d9f40a1b92dec44dc422a32/tracks not found 2024-05-29 16:53:33.811 ERROR (MainThread) [music_assistant.webserver] Error handling message: music/playlists/playlist_tracks: me/library/playlists/pl.c74ebd652d9f40a1b92dec44dc422a32/tracks not found

Don't mean to hijack, but also don't want to spam if it is the same root cause. Let me know if I should open another issue. Thanks. and BTW, this is awesome!

MarvinSchenkel commented 4 weeks ago

I am having a similar issue, but perhaps presents different. I can open the playlist, but will recieve an error "tracks not found". This happens with the apple playlists, but not always. i.e. some work and some don't. Oddly the only ones that I get the playlist picture don't work. The ones that do work none get the playlist picture. logs below.

2024-05-29 16:53:31.829 ERROR (MainThread) [music_assistant] Error doing task: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 98, in add_item_to_library await self.mass.metadata.get_metadata(item) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/metadata.py", line 334, in get_metadata await self.get_playlist_metadata(item) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/metadata.py", line 265, in get_playlist_metadata playlist_items = await self.mass.music.playlists.tracks(playlist.item_id, playlist.provider) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/playlists.py", line 62, in tracks tracks = await self._get_provider_playlist_tracks( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/playlists.py", line 379, in _get_provider_playlist_tracks for item in await provider.get_playlist_tracks(item_id, offset=offset, limit=limit): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/apple_music/__init__.py", line 253, in get_playlist_tracks for track in await self._get_all_items(endpoint, include="artists,catalog"): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/apple_music/__init__.py", line 534, in _get_all_items result = await self._get_data(endpoint, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/helpers/throttle_retry.py", line 72, in wrapper return await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/apple_music/__init__.py", line 556, in _get_data raise MediaNotFoundError(f"{endpoint} not found") music_assistant.common.models.errors.MediaNotFoundError: me/library/playlists/pl.c74ebd652d9f40a1b92dec44dc422a32/tracks not found 2024-05-29 16:53:33.811 ERROR (MainThread) [music_assistant.webserver] Error handling message: music/playlists/playlist_tracks: me/library/playlists/pl.c74ebd652d9f40a1b92dec44dc422a32/tracks not found

Don't mean to hijack, but also don't want to spam if it is the same root cause. Let me know if I should open another issue. Thanks. and BTW, this is awesome!

Can you provide some examples of playlist that are not working? If those playlists are your own, please make them public so I can access them and try to reproduce it.

smartmatic commented 4 weeks ago

@MarvinSchenkel Are you able to access my playlists?

MarvinSchenkel commented 4 weeks ago

@MarvinSchenkel Are you able to access my playlists?

Well no, I cannot find your username on apple music if I search for it and the playlists you linked are not public. When I click one of your links I get this: image

Can you maybe mark them as public?

smartmatic commented 4 weeks ago

If i follow this guideline there is no setting like make public.

This is how it looks like in my profile: am_playlist - 1

Where can i configure to make a playlist public?

MarvinSchenkel commented 4 weeks ago

If i follow this guideline there is no setting like make public.

This is how it looks like in my profile: IMG_2673

Where can i configure to make a playlist public? There are two things we can try:

  1. Open apple music via the web on a laptop and edit the playlist > make visible on profile:

image

  1. If that doesn't work, we can try to get the 'share link' of the playlist. E.g. image
chasut commented 4 weeks ago

Sure, here are a few. All of them are Apple Music playlists so should be accessible directly.

https://music.apple.com/us/playlist/pure-chill/pl.c74ebd652d9f40a1b92dec44dc422a32 https://music.apple.com/us/playlist/acoustic-memories/pl.97b3398e05f74257ac03d013b4726668

Just noticed something while I was pulling these. Both have double entries (two playlists, one with "https:/..." one with just "p..." neither work, but the first does get the playlist picture.

This one also doesn't work, but only a single entry and no playlist picture. https://music.apple.com/us/playlist/classic-rock-essentials/pl.1a7fd42205674dd282d106f533f4bea6

But this one works just fine but with no playlist picture, go figure! https://music.apple.com/us/playlist/dont-mess-with-texas/pl.3e854cd2fea14eadb57be1187e40dda1

The one thing they all have in common for me is that they are Apple Music playlists. The apple playlists that I renamed locally (broke the link) all work. even if I didn't change a song.

smartmatic commented 4 weeks ago

If i follow this guideline there is no setting like make public. This is how it looks like in my profile: IMG_2673 Where can i configure to make a playlist public? There are two things we can try:

  1. Open apple music via the web on a laptop and edit the playlist > make visible on profile:

image

  1. If that doesn't work, we can try to get the 'share link' of the playlist. E.g. image

I already share the playlist "Elektro" This is the link from the error log: playlist://p.aRbhERJABW Bildschirmfoto 2024-06-04 um 16 58 51

Here is in addition the link via share button: https://music.apple.com/de/playlist/elektro/pl.895a00b8490f42e1b01ad8db237fe451

MarvinSchenkel commented 4 weeks ago

Thanks everyone! Managed to reproduce it and already implemented a fix. Hang tight for the next beta to re-test it :-)

MarvinSchenkel commented 4 weeks ago

Beta 2 has just been released. Could you please retest? Be sure to completely remove and re-add the apple music provider after installing the new beta.

smartmatic commented 4 weeks ago

Beta 2 has just been released. Could you please retest? Be sure to completely remove and re-add the apple music provider after installing the new beta.

Great news, thanks a lot for your quick fix!

MarvinSchenkel commented 4 weeks ago

Beta 2 has just been released. Could you please retest? Be sure to completely remove and re-add the apple music provider after installing the new beta.

I removed Apple Music Provider and reinstalled the Add-On. Then i integrated the provider again. Unfortunately i am not yet able to open a Playlist.

2024-06-05 20:24:07.707 ERROR (MainThread) [music_assistant.webserver] Error handling message: music/playlists/get_playlist: playlist://p.aRbhERJABW not found on provider apple_music 2024-06-05 20:24:41.810 ERROR (MainThread) [music_assistant.webserver] Error handling message: music/playlists/get_playlist: playlist://p.NJYLhP6ERJD not found on provider apple_music 2024-06-05 20:25:29.473 ERROR (MainThread) [music_assistant.webserver] Error handling message: music/playlists/get_playlist: playlist://p.aRbhERJABW not found on provider apple_music

I am not sure if i made everything correct? Depending on the order of operations, you might see the error on beta 2 if you have nit removed the provider before updating. Are you absolutely sure you updated the addon and properly removed and readded the provider? If so, please enable debug logging, try again and provide a full log so I can see some more details

smartmatic commented 4 weeks ago

Sorry for the confusion. My fault but i can confirm that i can now open my playlists. My self created as well as Apple playlists. So it's working!

Thanks a lot! It's so cool to be able now to play music from Apple Music!!!

MarvinSchenkel commented 4 weeks ago

Sorry for the confusion. My fault but i can confirm that i can now open my playlists. My self created as well as Apple playlists. So it's working!

Thanks a lot! It's so cool to be able now to play music from Apple Music!!!

Awesome! No worries, happy it's all working well!

chasut commented 4 weeks ago

Much improved but sadly still having issues.

Each of the playlists started pulling tracks just fine until it tried to fetch the third page (101-150 presumably) and I got the same error as before. Was wondering if there is a limit and took a look at each of the playlists and they all have exactly 100 tracks. So I am thinking just a bit of cleanup on the eof or something.

But

I attempted to play one of the playlist and received an error "No playable items found". Same on all of the other playlists. So I played one of my own playlists and everything work as expected.

I then went back to one of the apple playlists and played just a single track off of the playlist and it played just fine. Once again attempted to play the playlist and same error. I double checked to make sure the "shuffle" wasn't on just in case it was something with the total tracks and randomizer.

Anyway hope that helps

MarvinSchenkel commented 4 weeks ago

Much improved but sadly still having issues.

Each of the playlists started pulling tracks just fine until it tried to fetch the third page (101-150 presumably) and I got the same error as before. Was wondering if there is a limit and took a look at each of the playlists and they all have exactly 100 tracks. So I am thinking just a bit of cleanup on the eof or something.

But

I attempted to play one of the playlist and received an error "No playable items found". Same on all of the other playlists. So I played one of my own playlists and everything work as expected.

I then went back to one of the apple playlists and played just a single track off of the playlist and it played just fine. Once again attempted to play the playlist and same error. I double checked to make sure the "shuffle" wasn't on just in case it was something with the total tracks and randomizer.

Anyway hope that helps

Are you sure you properly removed the entire provider and re added it? Might be that there were some left over faulty playlists in your MA library. If that seems fine, could you enable debug logging and find a playlist that doesn't work, share its URL and any logs related to the error?

Edit: could also be a cache related issue. I'm pretty sure I fixed the 100 limit issue. Try to manually refresh the cache via settings, core and the cache controller. If that fails, try deleting and installing the beta addon again, as this completely rebuilds the database

smartmatic commented 3 weeks ago

One of my playlists has almost 300 tracks and i am able to scroll through the playlist and play e.g. the last title from the playlist. So on my side no issues with a playlist larger than 100 titles.

chasut commented 3 weeks ago

Doh! My bad. No I didn't remove the provider and re-add. Just rushed in and tested. Just remove/re-add was not enough so in the process of re-installing the add-in. But, HA just updated the supervisor and it won't let me do that till I update.

So, fixing my blunder is still in-process. back soon.

chasut commented 3 weeks ago

Still no joy, same issue. To be clear, it is just those Apple playlists that have exactly 100 songs. I found one with 129 songs and it was fine, no error scrolling, and no problem playing the playlist. Unfortunately for me, a number of the Apple playlists I like have EXACTLY 100 songs.

Removed and re-added the add-on as well as the Apple Music Provider. Twice, actually, for some reason the playlists never loaded the first time.

chasut commented 3 weeks ago

BTW, love that the playlist pictures are coming across now.

MarvinSchenkel commented 3 weeks ago

Still no joy, same issue. To be clear, it is just those Apple playlists that have exactly 100 songs. I found one with 129 songs and it was fine, no error scrolling, and no problem playing the playlist. Unfortunately for me, a number of the Apple playlists I like have EXACTLY 100 songs.

Removed and re-added the add-on as well as the Apple Music Provider. Twice, actually, for some reason the playlists never loaded the first time.

So.. Wat exactly is the issue that remains after you had reinstalled the addon? I also noticed that for example the Classic rock playlist has exactly 100 songs. It seems to load fine here.

chasut commented 3 weeks ago

Hmm, so it is just me. I will completely nuke it and reload everything to see if that helps. Here are some details.

Apple Music playlists with exactly 100 songs (at least all I have tried) appear to load just fine but when pressing the play button on the playlist screen I receive the error "No playable items found". If I scroll down to the bottom of the playlist I get ...tracks not found. The log shows:

2024-06-06 07:48:36.070 WARNING (MainThread) [music_assistant.player_queues] Skipping Playlist(item_id='20', provider='library', name='Classic Rock Essentials', version='', sort_name='classic rock essentials', uri='library://playlist/20', external_ids=set(), media_type=<MediaType.PLAYLIST: 'playlist'>, provider_mappings={ProviderMapping(item_id='pl.1a7fd42205674dd282d106f533f4bea6', provider_domain='apple_music', provider_instance='apple_music--iTp3bC4o', available=True, audio_format=AudioFormat(content_type=<ContentType.UNKNOWN: '?'>, sample_rate=44100, bit_depth=16, channels=2, output_format_str='?', bit_rate=320), url=None, details=None)}, metadata=MediaItemMetadata(description="Immortal radio smashes spanning the ’60s all the way to the '90s.", review=None, explicit=None, images=[MediaItemImage(type=<ImageType.THUMB: 'thumb'>, path='https://is1-ssl.mzstatic.com/image/thumb/Features/v4/0b/ca/8a/0bca8aff-bb5a-5845-040b-b274a09e2516/eb19a238-36fe-4f02-bbcb-2652b59e752e.png/{w}x{h}SC.CAESS02.jpg', provider='apple_music--iTp3bC4o', remotely_accessible=True), MediaItemImage(type=<ImageType.FANART: 'fanart'>, path='/data/collage_images/751a398ab0d34ec4ad065c226cb6b754_fanart.jpg', provider='builtin', remotely_accessible=False)], genres={'Arena Rock', 'Hard Rock', 'Music', 'Metal', 'Rock', 'Blues-Rock'}, mood=None, style=None, copyright=None, lyrics=None, label=None, links=None, chapters=None, performers=None, preview=None, popularity=None, cache_checksum='2018-07-13T22:47:47Z', last_refresh=1717676832), favorite=True, position=None, owner='me', is_editable=0): catalog/us/playlists/pl.1a7fd42205674dd282d106f533f4bea6/tracks not found 2024-06-06 07:48:36.070 ERROR (MainThread) [music_assistant.webserver] Error handling message: player_queues/play_media: No playable items found

chasut commented 3 weeks ago

FYI, completely removed and re-built the add-on with an HA restart in the middle and getting the same results. Apple playlists with > 100 or < 100 songs work just fine. But if it works for you then something else must be up.

Only thing I can think of is to bring up MA in docker on a different machine architecture and see if it is different. Unfortunately will be out for the next few days.

Let me know if you have any other thoughts on how to troubleshoot from my end

MarvinSchenkel commented 3 weeks ago

FYI, completely removed and re-built the add-on with an HA restart in the middle and getting the same results. Apple playlists with > 100 or < 100 songs work just fine. But if it works for you then something else must be up.

Only thing I can think of is to bring up MA in docker on a different machine architecture and see if it is different. Unfortunately will be out for the next few days.

Let me know if you have any other thoughts on how to troubleshoot from my end

Just did some tests, I can reproduce this. Just to verify, the syncing of all playlists works fine now? The only issue you occur is with hitting 'play' on specific playlists (the ones with exactly 100 songs)?

chasut commented 3 weeks ago

Yes, syncing of all playlists works fine. Issue is hitting 'Play' or attempting to scroll past the end of apple playlists with exactly 100 songs.

MarvinSchenkel commented 3 weeks ago

Yes, syncing of all playlists works fine. Issue is hitting 'Play' or attempting to scroll past the end of apple playlists with exactly 100 songs.

Crystal clear! Will try to find some time this week to fix it

chasut commented 3 weeks ago

Just FYI. Installed the latest beta 2.1.0b3 and now none of my playlist will play "No playable items found". Did the full uninstall/re-install and same.

sp0ngeboobs commented 3 weeks ago

same bug. just today setup apple music provider.

MarvinSchenkel commented 3 weeks ago

same bug. just today setup apple music provider.

Beta 4 is coming out soon with a lot of fixes including this one

OzGav commented 3 weeks ago

2.1.0b4 is released please confirm if this is fixed

chasut commented 3 weeks ago

All of the playlists I tested, including those with exactly 100 songs, play as expected.

Two notes though:

  1. I am no longer testing with the beta add-on, but running in a separate docker. Ran into an issue that would not allow it to run on that hardware (logged separately) with airplay.
  2. I still had the issue of when scrolling past the end on those apple playlists with exactly 100 songs I would get an error. No issue for other playlists. However, it does recover and plays without issue.
MarvinSchenkel commented 3 weeks ago

All of the playlists I tested, including those with exactly 100 songs, play as expected.

Two notes though:

  1. I am no longer testing with the beta add-on, but running in a separate docker. Ran into an issue that would not allow it to run on that hardware (logged separately) with airplay.
  2. I still had the issue of when scrolling past the end on those apple playlists with exactly 100 songs I would get an error. No issue for other playlists. However, it does recover and plays without issue.

Yep I can confirm 2. Will fix this for the next beta

sp0ngeboobs commented 3 weeks ago

installed b4. playlists started playing without errors.

  1. Only 50 tracks are added to the queue. is it supposed to be?
  2. there is no track name or artist in the player attributes.
  3. there is no image of the song in the attributes of the player

cleared cache, rebooted MA. Anyone else like this?

sp0ngeboobs commented 3 weeks ago

ok i got it. the picture and the name of the track are not displayed only when you start the playlist. When you start one song from the tracks section, then everything is fine.

chasut commented 2 weeks ago

beta 5 working great. No issues with the scroll, everything playing and really like that the artwork is pulled straight away.

Thank you!