KoljaWindeler / ytube_music_player

YouTube music player for homeassistant
334 stars 53 forks source link

Cannot browse YTM playlist #313

Closed bonstio closed 3 months ago

bonstio commented 6 months ago

Using ytube_music_player integration Media Browsing Error is observed in the UI when clicking on library playlists e.g. 'Liked music' or other custom playlists.

It may be relevant to note this account is the lead account in a Family plan with an active subscription to Premium.

Repro steps

  1. Setup ytube_music_player, add card to a dashboard e.g.
    type: media-control
    entity: media_player.youtube_music
  2. From the media card, click browse
  3. Click Library playlists
  4. Click Liked music

image

Note that browsing 'Library songs' works.

Logs

2024-03-17 10:26:59.725 ERROR (MainThread) [custom_components.ytube_music_player.media_player] async_browse_media
2024-03-17 10:26:59.726 ERROR (MainThread) [custom_components.ytube_music_player.media_player] [S] async_check_api [E]                                                                                                                                        2024-03-17 10:27:00.324 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547068401856] Error handling message: Unknown error (unknown_error) bonstio from 192.168.4.16 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.Traceback (most recent call last):                                                                                                                                                                                                                              File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)                                                                                                                                                                                                                           File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1310, in websocket_browse_media
    payload = await player.async_browse_media(media_content_type, media_content_id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                             File "/config/custom_components/ytube_music_player/media_player.py", line 2076, in async_browse_media                                                                                                                                                           response = await build_item_response(self, payload)                                                                                                                                                                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                         File "/config/custom_components/ytube_music_player/browse_media.py", line 181, in build_item_response
    media = await hass.async_add_executor_job(media_library.get_playlist, search_id, BROWSER_LIMIT)                                                                                                                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                             File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run                                                                                                                                                                                  result = self.fn(*self.args, **self.kwargs)                                                                                                                                                                                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/mixins/playlists.py", line 109, in get_playlist                                                                                                                                                        results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + ["musicPlaylistShelfRenderer"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                             File "/usr/local/lib/python3.12/site-packages/ytmusicapi/navigation.py", line 92, in nav                                                                                                                                                                        raise err                                                                                                                                                                                                                                                   File "/usr/local/lib/python3.12/site-packages/ytmusicapi/navigation.py", line 86, in nav
    root = root[k]                                                                                                                                                                                                                                                       ~~~~^^^                                                                                                                                                                                                                                            KeyError: 'singleColumnBrowseResultsRenderer' 
DarcyDetlor commented 5 months ago

The same problem for me started a few days ago. YouTube Music updated the web interface to display the playlist image under the display of songs. I wonder if they changed the API slightly at the same time. I cannot play playlists anymore from my library of playlists.

gawleyc commented 5 months ago

The same problem for me started a few days ago. YouTube Music updated the web interface to display the playlist image under the display of songs. I wonder if they changed the API slightly at the same time. I cannot play playlists anymore from my library of playlists.

You get it sorted or still waiting on a fix?

I can play albums and single songs but if I choose any playlist it doesn't work.

DarcyDetlor commented 5 months ago

Hello, I have not found a solution. I think he is going to have to fix it.

Cheers,

Darcy Detlor @.**@.>

From: GamerWithAKid @.> Date: Thursday, March 28, 2024 at 6:37 PM To: KoljaWindeler/ytube_music_player @.> Cc: DarcyDetlor @.>, Comment @.> Subject: Re: [KoljaWindeler/ytube_music_player] Cannot browse YTM playlist (Issue #313)

The same problem for me started a few days ago. YouTube Music updated the web interface to display the playlist image under the display of songs. I wonder if they changed the API slightly at the same time. I cannot play playlists anymore from my library of playlists.

You get it sorted or still waiting on a fix?

I can play albums and single songs but if I choose any playlist it doesn't work.

— Reply to this email directly, view it on GitHubhttps://github.com/KoljaWindeler/ytube_music_player/issues/313#issuecomment-2026392634, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AU3GONGGPQYGRR33XDLQ5S3Y2SZVXAVCNFSM6AAAAABE2DDVJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRWGM4TENRTGQ. You are receiving this because you commented.Message ID: @.***>

DarcyDetlor commented 5 months ago

Ok, this is weird. This morning my YouTube has reverted to the old look, and the YouTube interface is now searching playlists. I’m guessing someone at YouTube broke some other things so they had to put it back.

Darcy Detlor @.**@.>

From: GamerWithAKid @.> Date: Thursday, March 28, 2024 at 6:37 PM To: KoljaWindeler/ytube_music_player @.> Cc: DarcyDetlor @.>, Comment @.> Subject: Re: [KoljaWindeler/ytube_music_player] Cannot browse YTM playlist (Issue #313)

The same problem for me started a few days ago. YouTube Music updated the web interface to display the playlist image under the display of songs. I wonder if they changed the API slightly at the same time. I cannot play playlists anymore from my library of playlists.

You get it sorted or still waiting on a fix?

I can play albums and single songs but if I choose any playlist it doesn't work.

— Reply to this email directly, view it on GitHubhttps://github.com/KoljaWindeler/ytube_music_player/issues/313#issuecomment-2026392634, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AU3GONGGPQYGRR33XDLQ5S3Y2SZVXAVCNFSM6AAAAABE2DDVJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRWGM4TENRTGQ. You are receiving this because you commented.Message ID: @.***>

gawleyc commented 5 months ago

Ok, this is weird. This morning my YouTube has reverted to the old look, and the YouTube interface is now searching playlists. I’m guessing someone at YouTube broke some other things so they had to put it back. Darcy Detlor @.**@.> From: GamerWithAKid @.> Date: Thursday, March 28, 2024 at 6:37 PM To: KoljaWindeler/ytube_music_player @.> Cc: DarcyDetlor @.>, Comment @.> Subject: Re: [KoljaWindeler/ytube_music_player] Cannot browse YTM playlist (Issue #313) The same problem for me started a few days ago. YouTube Music updated the web interface to display the playlist image under the display of songs. I wonder if they changed the API slightly at the same time. I cannot play playlists anymore from my library of playlists. You get it sorted or still waiting on a fix? I can play albums and single songs but if I choose any playlist it doesn't work. — Reply to this email directly, view it on GitHub<#313 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AU3GONGGPQYGRR33XDLQ5S3Y2SZVXAVCNFSM6AAAAABE2DDVJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRWGM4TENRTGQ. You are receiving this because you commented.Message ID: @.***>

Can confirm, it's working.

Like you said, YouTube must have sorted it on their end.

Good stuff!

bonstio commented 5 months ago

The problem remains exactly the same for me. I've removed and re-added but still cannot browse my 'Liked' playlist -- and most others too.

Logger: custom_components.ytube_music_player.media_player
Source: custom_components/ytube_music_player/media_player.py:256
integration: YouTube Music Player ([documentation](https://github.com/KoljaWindeler/ytube_music_player), [issues](https://github.com/KoljaWindeler/ytube_music_player/issues))
First occurred: 01:30:38 (10 occurrences)
Last logged: 01:31:58

[S] async_update [E]
[S] async_get_cipher [E]
[S] async_check_api ... - no valid API, try to login ... YouTube Api initialized ok, version: 1.4.2 [E]
[S] async_update_remote_player(Input speaker_group/ current ) [E]
[S] async_check_api [E]
bonstio commented 5 months ago

Wait I think the error has changed now!

KeyError: 'singleColumnBrowseResultsRenderer'
2024-04-03 01:39:50.673 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547519028288] Error handling message: Unknown error (unknown_error) bonstio from 192.168.4.16 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1310, in websocket_browse_media
    payload = await player.async_browse_media(media_content_type, media_content_id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ytube_music_player/media_player.py", line 2076, in async_browse_media
    response = await build_item_response(self, payload)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ytube_music_player/browse_media.py", line 181, in build_item_response
    media = await hass.async_add_executor_job(media_library.get_playlist, search_id, BROWSER_LIMIT)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/mixins/playlists.py", line 109, in get_playlist
    results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + ["musicPlaylistShelfRenderer"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/navigation.py", line 92, in nav
    raise err
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/navigation.py", line 86, in nav
    root = root[k]
           ~~~~^^^
KeyError: 'singleColumnBrowseResultsRenderer'
cherryocola commented 5 months ago

I am having the same problem

KoljaWindeler commented 5 months ago

oh boy, this is really annoying .. but it needs to be fixed in the ytmusicapi, I'll see if there is a ticket already open for this issue yes, it looks like this is it https://github.com/sigma67/ytmusicapi/issues/562

as this wasn't fixed and there is no real merge request in place it might take a few days. once @sigma67 releases a new version I'll add it to this integration as well... also: THANKS SIGMA for all the work you are doing!!

sigma67 commented 5 months ago

I'll try to make a fix happen tonight. Been sick for a week

KoljaWindeler commented 5 months ago

no rush, get well @sigma67

sigma67 commented 5 months ago

there is a working patch here https://github.com/sigma67/ytmusicapi/pull/573

if it doesn't work please provide response data for non-working playlists

hundredfire commented 4 months ago

332 I realized that I created a duplicate issue from this one. Is there any update?

hundredfire commented 4 months ago

great news. Thank you, @sigma67

bonstio commented 4 months ago

I'd hoped the 1.7 update would fix this. Sadly not.

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/navigation.py", line 101, in nav
    root = root[k]
           ~~~~^^^
KeyError: 'singleColumnBrowseResultsRenderer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1307, in websocket_browse_media
    payload = await player.async_browse_media(media_content_type, media_content_id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ytube_music_player/media_player.py", line 2172, in async_browse_media
    response = await build_item_response(self, payload)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ytube_music_player/browse_media.py", line 181, in build_item_response
    media = await hass.async_add_executor_job(media_library.get_playlist, search_id, BROWSER_LIMIT)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/mixins/playlists.py", line 109, in get_playlist
    results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + ["musicPlaylistShelfRenderer"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/navigation.py", line 105, in nav
    raise type(e)(f"Unable to find '{k}' using path {items!r} on {root!r}, exception: {e}")
KeyError: 'Unable to find \'singleColumnBrowseResultsRenderer\' using path [\'contents\',
hundredfire commented 4 months ago

I'd hoped the 1.7 update would fix this. Sadly not.

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/navigation.py", line 101, in nav
    root = root[k]
           ~~~~^^^
KeyError: 'singleColumnBrowseResultsRenderer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1307, in websocket_browse_media
    payload = await player.async_browse_media(media_content_type, media_content_id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ytube_music_player/media_player.py", line 2172, in async_browse_media
    response = await build_item_response(self, payload)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ytube_music_player/browse_media.py", line 181, in build_item_response
    media = await hass.async_add_executor_job(media_library.get_playlist, search_id, BROWSER_LIMIT)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/mixins/playlists.py", line 109, in get_playlist
    results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + ["musicPlaylistShelfRenderer"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ytmusicapi/navigation.py", line 105, in nav
    raise type(e)(f"Unable to find '{k}' using path {items!r} on {root!r}, exception: {e}")
KeyError: 'Unable to find \'singleColumnBrowseResultsRenderer\' using path [\'contents\',

It did work for me using a ytmusic-api 1.7.0 instance on a google colab:

A personal playlist queried withytmusic.get_playlist(playlistId="PLVzbblIKh5H6ZRU3AfVHLwemKwUp2UZKv")

returns:

{'owned': True,
 'id': 'PLVzbblIKh5H6ZRU3AfVHLwemKwUp2UZKv',
 'privacy': 'PRIVATE',
 'description': None,
 'title': 'Genshin alarm',
 'artists': [],
 'year': '2024',
 'views': None,
 'duration': '2+ hours',
 'trackCount': 163,
 'related': [],
 'tracks': [{'videoId': 'ghaz6x9Q-_4',
   'title': 'Dream Aria (Genshin Impact Main Theme Var.)',
   'artists': [{'name': 'Yu-Peng Chen', 'id': 'UCP-ZkQ1lMVrwJ-xcJEmAokg'},
    {'name': 'HOYO-MiX', 'id': 'UCJ4yjqc1XuGgiE35NsSSkYA'}],
   'album': {'name': 'Genshin Impact - The Wind and the Star Traveler (Original Game Soundtrack)',
    'id': 'MPREb_rzOpYVH6qow'},
   'likeStatus': 'INDIFFERENT',
   'inLibrary': None,
   'thumbnails': [{'url': 'https://lh3.googleusercontent.com/uiEOb5FUAfPaJ5PSCujle5o5mYxSBAEHvf2-UybnsHQiGleDF86zlMMzvTLn_4UZp1XB64x6YjR0CPOCIQ=w60-h60-l90-rj',
     'width': 60,
     'height': 60},
    {'url': 'https://lh3.googleusercontent.com/uiEOb5FUAfPaJ5PSCujle5o5mYxSBAEHvf2-UybnsHQiGleDF86zlMMzvTLn_4UZp1XB64x6YjR0CPOCIQ=w120-h120-l90-rj',
     'width': 120,
     'height': 120}],
   'isAvailable': True,
   'isExplicit': False,
   'videoType': 'MUSIC_VIDEO_TYPE_ATV',
   'views': None,
   'duration': '1:39',
   'duration_seconds': 99,
   'setVideoId': '2C98A09B9311E8B5'},
  {'videoId': '6k21sSDavWU',
   'title': "Moon in One's Cup",
   'artists': [{'name': 'Yu-Peng Chen', 'id': 'UCP-ZkQ1lMVrwJ-xcJEmAokg'},
    {'name': 'HOYO-MiX', 'id': 'UCJ4yjqc1XuGgiE35NsSSkYA'}],
   'album': {'name': 'Genshin Impact - Jade Moon Upon a Sea of Clouds (Original Game Soundtrack)',
    'id': 'MPREb_I28gV8bm4Ev'},
   'likeStatus': 'INDIFFERENT',
   'inLibrary': None,
   'thumbnails': [{'url': 'https://lh3.googleusercontent.com/Hg3I2tH3VVyvgDiRezlgYhukDqzsLoXBrjGFHMnXLYr1IjKPTOxW7nGAdnn_xb3oqJa9A9ub6QRnUmDa=w60-h60-l90-rj',
     'width': 60,
     'height': 60},
    {'url': 'https://lh3.googleusercontent.com/Hg3I2tH3VVyvgDiRezlgYhukDqzsLoXBrjGFHMnXLYr1IjKPTOxW7nGAdnn_xb3oqJa9A9ub6QRnUmDa=w120-h120-l90-rj',
     'width': 120,
     'height': 120}],
   'isAvailable': True,
   'isExplicit': False,
   'videoType': 'MUSIC_VIDEO_TYPE_ATV',
   'views': None,
   'duration': '1:58',
   'duration_seconds': 118,
   'setVideoId': '6C992A3B5EB60D08'},
[etc.]

Also, the equivalent project "Music assistant" just updated with this version of ytmusic-api and I can confirm that it does work

sigma67 commented 4 months ago

@bonstio you are not using 1.7

It's impossible to get this error on 1.7

bonstio commented 4 months ago

OK, my bad. I will check.

Very strange though. I saw the udpate, I took it and duly restarted HA. Upon seeing the same error, I even re-downloaded the integration and re-setup.

Nonetheless, I will get to the bottom of this and update here. Sorry for the noise.

bonstio commented 4 months ago

Right. I've checked. It certainly looks like I'm running the latest and greatest ytube_music_player, versino 20240505.01 yet I still see this error.

➜  ~ cat /config/custom_components/ytube_music_player/manifest.json 
{
  "domain": "ytube_music_player",
  "name": "YouTube Music Player",
  "codeowners": [
    "@KoljaWindeler",
    "@mang1985"
  ],
  "config_flow": true,
  "dependencies": [
    "persistent_notification"
  ],
  "documentation": "https://github.com/KoljaWindeler/ytube_music_player",
  "iot_class": "cloud_polling",
  "issue_tracker": "https://github.com/KoljaWindeler/ytube_music_player/issues",
  "requirements": [
    "ytmusicapi==1.6.0",
    "pytube==15.0.0",
    "integrationhelper==0.2.2"
  ],
  "version": "20240505.01"
}

I have configured a card bound to media_player.ytube_music_player. Whenever I do:

Browse Media -> Library Playlists -> Liked Music

I see the an error from custom_components/ytube_music_player/media_player.py:2155. If this is a new issue, I'm happy to file a new issue to track.

bonstio commented 3 months ago

This is now working. I don't know what changed but, as mentioned above, I was pretty sure I had updated. Nonetheless, I'm happy to close this now.

wout-junius commented 2 weeks ago

So I am running into the same issue now aswell. I just installed it, dit setup and have this issue I am running version 20240505.01

So to those who don't have it anymore how did you fix it?

gawleyc commented 2 weeks ago

So I am running into the same issue now aswell. I just installed it, dit setup and have this issue I am running version 20240505.01

So to those who don't have it anymore how did you fix it?

I'm still having issues as well.

Noticed this related issue - https://github.com/KoljaWindeler/ytube_music_player/issues/356

Someone mentioned a fix, I have tried to update the files manually on my HomeAssistant but still not working.

All the other options like "Music Assistant" all required paid subscription to YouTube Music.

Might need to look into downloading all music locally and playing it that way....

bonstio commented 2 weeks ago

Despite filing this issue, I can actually no longer reproduce.

I have a paid version of YTM.

wout-junius commented 2 weeks ago

Despite filing this issue, I can actually no longer reproduce.

I have a paid version of YTM.

I also do have YTM Premium