[GH-ISSUE #113] keyError while getting liked songs #79

Closed
opened 2026-02-27 22:07:54 +03:00 by kerem · 11 comments
Owner

Originally created by @zak1388 on GitHub (Dec 2, 2020).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/113

I got this error after calling get_liked_songs().

Traceback (most recent call last): File "ytmusic.py", line 5, in <module> liked_songs = ytmusic.get_playlist(playlistId='LM') File "/home/zak/.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'

Tested on Ubuntu 20.04, using python 3.8.5

Originally created by @zak1388 on GitHub (Dec 2, 2020). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/113 I got this error after calling `get_liked_songs()`. `Traceback (most recent call last): File "ytmusic.py", line 5, in <module> liked_songs = ytmusic.get_playlist(playlistId='LM') File "/home/zak/.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'` Tested on Ubuntu 20.04, using python 3.8.5
kerem closed this issue 2026-02-27 22:07:55 +03:00
Author
Owner

@sigma67 commented on GitHub (Dec 2, 2020):

Have you liked any songs on this account? Do you see your liked songs when you go to https://music.youtube.com/playlist?list=LM?

<!-- gh-comment-id:737538607 --> @sigma67 commented on GitHub (Dec 2, 2020): Have you liked any songs on this account? Do you see your liked songs when you go to https://music.youtube.com/playlist?list=LM?
Author
Owner

@zak1388 commented on GitHub (Dec 3, 2020):

Yes, there's about 980 songs there

<!-- gh-comment-id:737812661 --> @zak1388 commented on GitHub (Dec 3, 2020): Yes, there's about 980 songs there
Author
Owner

@sigma67 commented on GitHub (Dec 3, 2020):

The other library calls work for you? i.e. get_library_playlists

<!-- gh-comment-id:737841148 --> @sigma67 commented on GitHub (Dec 3, 2020): The other library calls work for you? i.e. `get_library_playlists`
Author
Owner

@zak1388 commented on GitHub (Dec 4, 2020):

Nah it just returns a bunch of playlists called "test", and i cant access the playlist ids on the website either.

<!-- gh-comment-id:738644801 --> @zak1388 commented on GitHub (Dec 4, 2020): Nah it just returns a bunch of playlists called "test", and i cant access the playlist ids on the website either.
Author
Owner

@sigma67 commented on GitHub (Dec 4, 2020):

That is very vague, please provide more specifics. This is impossible to debug at this point.

<!-- gh-comment-id:738689199 --> @sigma67 commented on GitHub (Dec 4, 2020): That is very vague, please provide more specifics. This is impossible to debug at this point.
Author
Owner

@zak1388 commented on GitHub (Dec 4, 2020):

[{'title': 'test', 'playlistId': 'PLYpXmfKMEkF612pd0h_ICGCL_Ku9cAPE7', 'thumbnails': [{'url': 'https://lh3.googleusercontent.com/FoVQFdW6zBi3sNA_yZJSV3VTWmi0belhhFzleuEbn27utkirstj1woXHfWmWqkNyHla37ZFbk_F6jvVV=w226-h226-l90-rj', 'width': 226, 'height': 226}, {'url': 'https://lh3.googleusercontent.com/FoVQFdW6zBi3sNA_yZJSV3VTWmi0belhhFzleuEbn27utkirstj1woXHfWmWqkNyHla37ZFbk_F6jvVV=w544-h544-l90-rj', 'width': 544, 'height': 544}], 'count': '1'}, {'title': 'test', 'playlistId': 'PLYpXmfKMEkF4HdftoyUjGh1S9BZBptvPt', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3nTWReOwPrwHjPF5BprvzcbEpmMRw', 'width': 400, 'height': 225}, {'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/hq720.jpg?sqp=-oaymwEXCKAGEMIDIAQqCwjVARCqCBh4INgESFo&rs=AMzJL3ldgnXFtqgQDnCMo_NfhGcXcqqbdw', 'width': 800, 'height': 450}], 'count': '1'}, {'title': 'test', 'playlistId': 'PLYpXmfKMEkF5CIUITqbqRu_gLs0nZAx1G', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3nTWReOwPrwHjPF5BprvzcbEpmMRw', 'width': 400, 'height': 225}, {'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/hq720.jpg?sqp=-oaymwEXCKAGEMIDIAQqCwjVARCqCBh4INgESFo&rs=AMzJL3ldgnXFtqgQDnCMo_NfhGcXcqqbdw', 'width': 800, 'height': 450}], 'count': '1'}, {'title': 'test', 'playlistId': 'PLYpXmfKMEkF6uAkXZP_5X9fnUyfQTv5RR', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3nTWReOwPrwHjPF5BprvzcbEpmMRw', 'width': 400, 'height': 225}, {'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/hq720.jpg?sqp=-oaymwEXCKAGEMIDIAQqCwjVARCqCBh4INgESFo&rs=AMzJL3ldgnXFtqgQDnCMo_NfhGcXcqqbdw', 'width': 800, 'height': 450}], 'count': '1'}]
Basically it returns playlists, but these aren't any of them in my library, and i cant access them using their playlistIds

<!-- gh-comment-id:738693918 --> @zak1388 commented on GitHub (Dec 4, 2020): `[{'title': 'test', 'playlistId': 'PLYpXmfKMEkF612pd0h_ICGCL_Ku9cAPE7', 'thumbnails': [{'url': 'https://lh3.googleusercontent.com/FoVQFdW6zBi3sNA_yZJSV3VTWmi0belhhFzleuEbn27utkirstj1woXHfWmWqkNyHla37ZFbk_F6jvVV=w226-h226-l90-rj', 'width': 226, 'height': 226}, {'url': 'https://lh3.googleusercontent.com/FoVQFdW6zBi3sNA_yZJSV3VTWmi0belhhFzleuEbn27utkirstj1woXHfWmWqkNyHla37ZFbk_F6jvVV=w544-h544-l90-rj', 'width': 544, 'height': 544}], 'count': '1'}, {'title': 'test', 'playlistId': 'PLYpXmfKMEkF4HdftoyUjGh1S9BZBptvPt', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3nTWReOwPrwHjPF5BprvzcbEpmMRw', 'width': 400, 'height': 225}, {'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/hq720.jpg?sqp=-oaymwEXCKAGEMIDIAQqCwjVARCqCBh4INgESFo&rs=AMzJL3ldgnXFtqgQDnCMo_NfhGcXcqqbdw', 'width': 800, 'height': 450}], 'count': '1'}, {'title': 'test', 'playlistId': 'PLYpXmfKMEkF5CIUITqbqRu_gLs0nZAx1G', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3nTWReOwPrwHjPF5BprvzcbEpmMRw', 'width': 400, 'height': 225}, {'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/hq720.jpg?sqp=-oaymwEXCKAGEMIDIAQqCwjVARCqCBh4INgESFo&rs=AMzJL3ldgnXFtqgQDnCMo_NfhGcXcqqbdw', 'width': 800, 'height': 450}], 'count': '1'}, {'title': 'test', 'playlistId': 'PLYpXmfKMEkF6uAkXZP_5X9fnUyfQTv5RR', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3nTWReOwPrwHjPF5BprvzcbEpmMRw', 'width': 400, 'height': 225}, {'url': 'https://i.ytimg.com/vi/bx1Bh8ZvH84/hq720.jpg?sqp=-oaymwEXCKAGEMIDIAQqCwjVARCqCBh4INgESFo&rs=AMzJL3ldgnXFtqgQDnCMo_NfhGcXcqqbdw', 'width': 800, 'height': 450}], 'count': '1'}]` Basically it returns playlists, but these aren't any of them in my library, and i cant access them using their playlistIds
Author
Owner

@sigma67 commented on GitHub (Dec 4, 2020):

If these aren't the right playlists you're probably using wrong credentials. Are you sure you used a request from your actual account for setup?

If you are, please provide the code you're using to setup the YTMusic instance.

<!-- gh-comment-id:738694925 --> @sigma67 commented on GitHub (Dec 4, 2020): If these aren't the right playlists you're probably using wrong credentials. Are you sure you used a request from your actual account for setup? If you are, please provide the code you're using to setup the YTMusic instance.
Author
Owner

@zak1388 commented on GitHub (Dec 4, 2020):

Alright, ill try setting the auth headers again

<!-- gh-comment-id:738695359 --> @zak1388 commented on GitHub (Dec 4, 2020): Alright, ill try setting the auth headers again
Author
Owner

@zak1388 commented on GitHub (Dec 4, 2020):

Okay so i set the headers using YTMusic.setup('headers_auth.json') just like the instructions. That worked fine so i set the instance to a variable ytm = YTMusic('headers_auth.json') then called print(ytm.get_library_playlists()) just to check the output. And I still got the same output from the earlier comment.

<!-- gh-comment-id:738699081 --> @zak1388 commented on GitHub (Dec 4, 2020): Okay so i set the headers using `YTMusic.setup('headers_auth.json')` just like the instructions. That worked fine so i set the instance to a variable `ytm = YTMusic('headers_auth.json')` then called `print(ytm.get_library_playlists())` just to check the output. And I still got the same output from the earlier comment.
Author
Owner

@sigma67 commented on GitHub (Dec 4, 2020):

Again, are you sure you're using the right account? Do you have brand accounts?

<!-- gh-comment-id:738722171 --> @sigma67 commented on GitHub (Dec 4, 2020): Again, are you sure you're using the right account? Do you have brand accounts?
Author
Owner

@zak1388 commented on GitHub (Dec 4, 2020):

Whoops, yep i think thats it, sorry about that. All good now, thanks man

<!-- gh-comment-id:738832654 --> @zak1388 commented on GitHub (Dec 4, 2020): Whoops, yep i think thats it, sorry about that. All good now, thanks man
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#79
No description provided.