[GH-ISSUE #143] Persistent Playlist Error #107

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

Originally created by @k-a-r-g on GitHub (Jan 5, 2021).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/143

Hello,

I know this has been covered in the forum already, but non of the suggested solutions seems to work for me. A.so the log file asks me to open an issue :)

I have just installed the integration for the first time, followed all instructions, updated to the latest version in HACS, but get the following error:
2021-01-05 07:48:57 ERROR (SyncWorker_12) [custom_components.ytube_music_player.media_player] Traceback (most recent call last): File "/config/custom_components/ytube_music_player/media_player.py", line 995, in play_media self._tracks = self._api.get_playlist(playlistId=media_id,limit=999)['tracks'] File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/playlists.py", line 100, in get_playlist playlist['tracks'].extend(parse_playlist_items(results['contents'])) KeyError: 'contents'

After reading several posts on the forum, I made sure that:

  • I have a playlists (currently the automatic "Your likes" and "Last Uploads" as well as a custom one.
  • I have populated Albums, Artists, Songs and Subsciptions
  • each of the above, including the playlists, has more than one entry

However, none of the tried solutions solved the issue.

Thanks a lot in advance.

Best,
Timm

Originally created by @k-a-r-g on GitHub (Jan 5, 2021). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/143 Hello, I know this has been covered in the forum already, but non of the suggested solutions seems to work for me. A.so the log file asks me to open an issue :) I have just installed the integration for the first time, followed all instructions, updated to the latest version in HACS, but get the following error: `2021-01-05 07:48:57 ERROR (SyncWorker_12) [custom_components.ytube_music_player.media_player] Traceback (most recent call last): File "/config/custom_components/ytube_music_player/media_player.py", line 995, in play_media self._tracks = self._api.get_playlist(playlistId=media_id,limit=999)['tracks'] File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/playlists.py", line 100, in get_playlist playlist['tracks'].extend(parse_playlist_items(results['contents'])) KeyError: 'contents'` After reading several posts on the forum, I made sure that: - I have a playlists (currently the automatic "Your likes" and "Last Uploads" as well as a custom one. - I have populated Albums, Artists, Songs and Subsciptions - each of the above, including the playlists, has more than one entry However, none of the tried solutions solved the issue. Thanks a lot in advance. Best, Timm
kerem closed this issue 2026-02-27 22:08:04 +03:00
Author
Owner

@sigma67 commented on GitHub (Jan 5, 2021):

How many items does the playlist have that you're trying to view? Does this error happen every time you access it? Is it a private playlist or could you make it public for us to test it?

<!-- gh-comment-id:754512641 --> @sigma67 commented on GitHub (Jan 5, 2021): How many items does the playlist have that you're trying to view? Does this error happen every time you access it? Is it a private playlist or could you make it public for us to test it?
Author
Owner

@k-a-r-g commented on GitHub (Jan 6, 2021):

Hi, thanks for the quick reply.
It is the "Your Likes" Playlist with currently two entries. I have increased the item count to five songs, but behavior is unchanged. Zes, it happens everytime. Unfortunately, I believe YouTube does not allow to make that one public.

I enabled a more detailed error logging and get the following information in addition to what ahs been posted above:
2021-01-06 09:31:31 DEBUG (SyncWorker_2) [custom_components.ytube_music_player.media_player] _update_playlists 2021-01-06 09:31:32 DEBUG (SyncWorker_2) [custom_components.ytube_music_player.media_player] - 1 Playlists loaded 2021-01-06 09:31:32 DEBUG (SyncWorker_2) [custom_components.ytube_music_player.media_player] - Failed to get_playlist count for playlist ID 'LM' setting it to 25

<!-- gh-comment-id:755164258 --> @k-a-r-g commented on GitHub (Jan 6, 2021): Hi, thanks for the quick reply. It is the "Your Likes" Playlist with currently two entries. I have increased the item count to five songs, but behavior is unchanged. Zes, it happens everytime. Unfortunately, I believe YouTube does not allow to make that one public. I enabled a more detailed error logging and get the following information in addition to what ahs been posted above: `2021-01-06 09:31:31 DEBUG (SyncWorker_2) [custom_components.ytube_music_player.media_player] _update_playlists 2021-01-06 09:31:32 DEBUG (SyncWorker_2) [custom_components.ytube_music_player.media_player] - 1 Playlists loaded 2021-01-06 09:31:32 DEBUG (SyncWorker_2) [custom_components.ytube_music_player.media_player] - Failed to get_playlist count for playlist ID 'LM' setting it to 25`
Author
Owner

@sigma67 commented on GitHub (Jan 6, 2021):

Failed to get_playlist count for playlist ID 'LM' setting it to 25

@KoljaWindeler any idea what is causing this?

<!-- gh-comment-id:755433431 --> @sigma67 commented on GitHub (Jan 6, 2021): > Failed to get_playlist count for playlist ID 'LM' setting it to 25 @KoljaWindeler any idea what is causing this?
Author
Owner

@KoljaWindeler commented on GitHub (Jan 6, 2021):

Are you using a Mini-Media-Player link to start this playlist or how to you start the playlist.

Looks like you are calling the service with "LM" as Id. This changed with the last version (my code) and isn't supported anymore. Please use the corresponding playlist_id ...

Edit: please read https://github.com/KoljaWindeler/ytube_music_player#shortcuts and the service chapter below

<!-- gh-comment-id:755479445 --> @KoljaWindeler commented on GitHub (Jan 6, 2021): Are you using a Mini-Media-Player link to start this playlist or how to you start the playlist. Looks like you are calling the service with "LM" as Id. This changed with the last version (my code) and isn't supported anymore. Please use the corresponding playlist_id ... Edit: please read https://github.com/KoljaWindeler/ytube_music_player#shortcuts and the service chapter below
Author
Owner

@k-a-r-g commented on GitHub (Jan 7, 2021):

So far I was not actively starting a playlist at all, and I guess that boils down to be the problem.
The loading of the integration during startup already prompted the error. Similarly, restarting the integration through Mini-Media-Player interface throws the error.
However, after your questions, I triggered a specific playlist through manually calling a service - and that worked well without any errors.
Is there a way to avoid loading LM playlist by default?

<!-- gh-comment-id:755916839 --> @k-a-r-g commented on GitHub (Jan 7, 2021): So far I was not actively starting a playlist at all, and I guess that boils down to be the problem. The loading of the integration during startup already prompted the error. Similarly, restarting the integration through Mini-Media-Player interface throws the error. However, after your questions, I triggered a specific playlist through manually calling a service - and that worked well without any errors. Is there a way to avoid loading LM playlist by default?
Author
Owner

@KoljaWindeler commented on GitHub (Jan 7, 2021):

Ah .. ok .. my bad .. I was a bit in a rush yesterday and only read it completely now ..
The added debug information is the key here ... you are right: this is during the init_phase.
During that phase my code requests all playlists from your account with

self._api.get_library_playlists(limit = 99)

the LM (liked music) is autogenerated and a somewhat special .. it will not tell you how many tracks are in the list (['count']) .. but my understanding was, that @sigma67 fixed that already. Didn't you?

My workaround was to request the playlist extra information with:

self._api.get_playlist(playlistId=playlist['playlistId'])

and that triggers the error .. which should total work ... so the ticket feels justified :)

Could you check witch version of the api you are using? it should be somewhere in the log further up and be 0.12.2 just to be sure. Also: Are you using the somewhat latest version? At least something from 202101**?

Kolja

<!-- gh-comment-id:755922931 --> @KoljaWindeler commented on GitHub (Jan 7, 2021): Ah .. ok .. my bad .. I was a bit in a rush yesterday and only read it completely now .. The added debug information is the key here ... you are right: this is during the init_phase. During that phase my code requests all playlists from your account with `self._api.get_library_playlists(limit = 99)` the LM (liked music) is autogenerated and a somewhat special .. it will not tell you how many tracks are in the list (['count']) .. but my understanding was, that @sigma67 fixed that already. Didn't you? My workaround was to request the playlist extra information with: `self._api.get_playlist(playlistId=playlist['playlistId'])` and that triggers the error .. which should total work ... so the ticket feels justified :) Could you check witch version of the api you are using? it should be somewhere in the log further up and be 0.12.2 just to be sure. Also: Are you using the somewhat latest version? At least something from 202101**? Kolja
Author
Owner

@k-a-r-g commented on GitHub (Jan 7, 2021):

Hi,
glad I did not waste your time with a config error :)
Yes, it is using API version 0.12.2
2021-01-06 19:40:02 DEBUG (SyncWorker_4) [custom_components.ytube_music_player.media_player] - YouTube Api version: 0.12.2
As for the ytube media player, I struggle to find the version number. Installation was through HACS and no available updates are displayed. Does that help?

<!-- gh-comment-id:755932682 --> @k-a-r-g commented on GitHub (Jan 7, 2021): Hi, glad I did not waste your time with a config error :) Yes, it is using API version 0.12.2 `2021-01-06 19:40:02 DEBUG (SyncWorker_4) [custom_components.ytube_music_player.media_player] - YouTube Api version: 0.12.2` As for the ytube media player, I struggle to find the version number. Installation was through HACS and no available updates are displayed. Does that help?
Author
Owner

@sigma67 commented on GitHub (Jan 7, 2021):

The way the exception handler is implemented we can't be sure that it was caused by the count, since the original exception is not printed.

github.com/KoljaWindeler/ytube_music_player@f4219bd5c2/custom_components/ytube_music_player/media_player.py (L694-L706)

Assuming that the original error at the very top also relates to the same issue, it seems the 'contents' key is missing again. This is the same problem we are facing in several other issues, likely related to a 403 error.

<!-- gh-comment-id:756013217 --> @sigma67 commented on GitHub (Jan 7, 2021): The way the exception handler is implemented we can't be sure that it was caused by the count, since the original exception is not printed. https://github.com/KoljaWindeler/ytube_music_player/blob/f4219bd5c2643a839ff030ffd90c415d244397ec/custom_components/ytube_music_player/media_player.py#L694-L706 Assuming that the original error at the very top also relates to the same issue, it seems the 'contents' key is missing again. This is the same problem we are facing in several other issues, likely related to a 403 error.
Author
Owner

@KoljaWindeler commented on GitHub (Jan 7, 2021):

dang it .. the longer I read about it, the stranger it gets.

The error at the very top points to this line, right:
github.com/KoljaWindeler/ytube_music_player@ef9ebb8550/custom_components/ytube_music_player/media_player.py (L995)

"- Failed to get_playlist count for playlist ID 'LM' setting it to 25" is in a total different place: github.com/KoljaWindeler/ytube_music_player@ef9ebb8550/custom_components/ytube_music_player/media_player.py (L660)

So after all you might be right .. bad cookie problem?
I've just updated my integration to try a login and grab a lib_playlist right after creating the header file .. maybe that will help in the future to avoid problems like this ..

So @k-a-r-g could you try to grab the cookie again? Maybe in a incognito session

<!-- gh-comment-id:756426054 --> @KoljaWindeler commented on GitHub (Jan 7, 2021): dang it .. the longer I read about it, the stranger it gets. The error at the very top points to this line, right: https://github.com/KoljaWindeler/ytube_music_player/blob/ef9ebb855009e7b254ddfb07989759ba7e3e0a1c/custom_components/ytube_music_player/media_player.py#L995 "- Failed to get_playlist count for playlist ID 'LM' setting it to 25" is in a total different place: https://github.com/KoljaWindeler/ytube_music_player/blob/ef9ebb855009e7b254ddfb07989759ba7e3e0a1c/custom_components/ytube_music_player/media_player.py#L660 So after all you might be right .. bad cookie problem? I've just updated my integration to try a login and grab a lib_playlist right after creating the header file .. maybe that will help in the future to avoid problems like this .. So @k-a-r-g could you try to grab the cookie again? Maybe in a incognito session
Author
Owner

@k-a-r-g commented on GitHub (Jan 8, 2021):

Hello,
unfortunately, the error persists after the update.
Grabbing and posting the cookie again failed, due to the following message by the gui frontend of the integration:
2021-01-08 07:39:36 ERROR (MainThread) [custom_components.ytube_music_player.const] Field 'X-Goog-AuthUser' not found!

Checking the cookie, the X-Goog-AuthUSer field was present. Similarly, copy/pasting cookie information from the existing ytube_header.json file threw the same frontend error.

Unfortunatelz I have to go to work now, but I can trz to manually create the cookie file in the evening...

<!-- gh-comment-id:756609366 --> @k-a-r-g commented on GitHub (Jan 8, 2021): Hello, unfortunately, the error persists after the update. Grabbing and posting the cookie again failed, due to the following message by the gui frontend of the integration: 2021-01-08 07:39:36 ERROR (MainThread) [custom_components.ytube_music_player.const] Field 'X-Goog-AuthUser' not found! Checking the cookie, the X-Goog-AuthUSer field was present. Similarly, copy/pasting cookie information from the existing ytube_header.json file threw the same frontend error. Unfortunatelz I have to go to work now, but I can trz to manually create the cookie file in the evening...
Author
Owner

@KoljaWindeler commented on GitHub (Jan 8, 2021):

Jep, that's indeed a bug. I've seen it yesterday and fixed it already. Will take a few days as that release will contain a boatload of new features.

You can change the string to lower in github.com/KoljaWindeler/ytube_music_player@a9d729b906/custom_components/ytube_music_player/const.py (L236)

elif(c.find('X-Goog-AuthUser')

To

elif(c.find('x-goog-authuser')

<!-- gh-comment-id:756696752 --> @KoljaWindeler commented on GitHub (Jan 8, 2021): Jep, that's indeed a bug. I've seen it yesterday and fixed it already. Will take a few days as that release will contain a boatload of new features. You can change the string to lower in https://github.com/KoljaWindeler/ytube_music_player/blob/a9d729b9065b53eab30c324389b517c97d174f48/custom_components/ytube_music_player/const.py#L236 elif(c.find('X-Goog-AuthUser') To elif(c.find('x-goog-authuser')
Author
Owner

@sigma67 commented on GitHub (Jan 10, 2021):

Is there still a potential error within ytmusicapi or can we close this as well?

<!-- gh-comment-id:757556751 --> @sigma67 commented on GitHub (Jan 10, 2021): Is there still a potential error within ytmusicapi or can we close this as well?
Author
Owner

@KoljaWindeler commented on GitHub (Jan 11, 2021):

hmm not sure
the new version of my code should fix the bug with the caps written x-goog-auth

<!-- gh-comment-id:758081566 --> @KoljaWindeler commented on GitHub (Jan 11, 2021): hmm not sure the new version of my code should fix the bug with the caps written x-goog-auth
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#107
No description provided.