[GH-ISSUE #320] "get_library_upload_songs" and "get_library_upload_artists" methods fail returning empty list #247

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

Originally created by @rvaquerizor on GitHub (Nov 30, 2022).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/320

Hello.

Not sure exactly when it started happening, but the YTMusic client returns empty list [] when calling:
get_library_upload_songs
and
get_library_upload_artists

(using different limit param values does not have any impact)

Actually, my lilbrary of uploaded songs/artists constains more than 1000 songs and more than 300 artists.
When I use the browser, I can find/play them without any problem.

For the empty list problem, when I set a breakpoint, I can see the problem is around these lines in code of the method:

     43         if order is not None:
     44             body["params"] = prepare_order_params(order)
     45         response = self._send_request(endpoint, body)
---> 46         results = get_library_contents(response, MUSIC_SHELF)

The response variable has a lot of content:

ipdb> response
{'responseContext': {'serviceTrackingParams': [{'service': 'GFEEDBACK', 'params': [{'key': 'browse_id', 'value': 'FEmusic_library_privately_owned_tracks'}, {'key': 'browse_id_prefix', 'value': ''}, {'key': 'logged_in', 'value': '1'}, {'key': 'e', 'value': '1714252,23804281,23882685,23918597,23934970,23946420,23966208,23983296,23998056,24001373,24002022,24002025,24004644,24007246,24034168,24036947,24077241,24080738,24120820,24135310,24140247,24161116,24162920,24164186,24169501,24181174,24187043,24187377,24191629,24197450,24199724,24200839,24209350,24211178,24216167,2421
....

But results, which is the returned value of get_library_contents using the previous response, is None:

ipdb> results is None
True
ipdb> l
     42         validate_order_parameter(order)
     43         if order is not None:
     44             body["params"] = prepare_order_params(order)
     45         response = self._send_request(endpoint, body)
     46         results = get_library_contents(response, MUSIC_SHELF)
---> 47         if results is None:

Something similar happens with uploaded artists:

ipdb> self.client.get_library_upload_artists()
[]

As I said, getting an uploaded artist individually works fine:

ipdb> self.client.get_library_upload_artist("FEmusic_library_privately_owned_artist_detaila_XXXXXXXXXXXXXX")
[{'entityId': 't_po_HHHHHHHHHHHHHHH', 'videoId': 'YYYYYYYYYYYYY', 'title': '......

Any idea what is happening here?

I have tried to use the latest commit on master branch, but it fails the same way.

Using v0.23.0 returns a different error

  File "/mypath", line 128, in get_songs
    return self.client.get_library_upload_songs(limit=config["song"]["limit"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/hmypath, line 46, in get_library_upload_songs
    results = find_object_by_key(nav(response, SINGLE_COLUMN_TAB + SECTION_LIST),
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/mypath", line 74, in nav
    raise err

  File "/mypath", line 68, in nav
    root = root[k]
           ~~~~^^^

KeyError: 'contents'

My environment is:

  • Ubuntu 22.04.1 LTS
  • YTMusic API v0.24.0
  • python 3.11

Thanks a lot.

Originally created by @rvaquerizor on GitHub (Nov 30, 2022). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/320 Hello. Not sure exactly when it started happening, but the YTMusic client returns empty list [] when calling: _get_library_upload_songs_ and _get_library_upload_artists_ (using different _limit_ param values does not have any impact) Actually, my lilbrary of uploaded songs/artists constains more than 1000 songs and more than 300 artists. When I use the browser, I can find/play them without any problem. For the empty list problem, when I set a breakpoint, I can see the problem is around these lines in code of the method: ``` 43 if order is not None: 44 body["params"] = prepare_order_params(order) 45 response = self._send_request(endpoint, body) ---> 46 results = get_library_contents(response, MUSIC_SHELF) ``` The response variable has a lot of content: ``` ipdb> response {'responseContext': {'serviceTrackingParams': [{'service': 'GFEEDBACK', 'params': [{'key': 'browse_id', 'value': 'FEmusic_library_privately_owned_tracks'}, {'key': 'browse_id_prefix', 'value': ''}, {'key': 'logged_in', 'value': '1'}, {'key': 'e', 'value': '1714252,23804281,23882685,23918597,23934970,23946420,23966208,23983296,23998056,24001373,24002022,24002025,24004644,24007246,24034168,24036947,24077241,24080738,24120820,24135310,24140247,24161116,24162920,24164186,24169501,24181174,24187043,24187377,24191629,24197450,24199724,24200839,24209350,24211178,24216167,2421 .... ``` But results, which is the returned value of get_library_contents using the previous response, is None: ``` ipdb> results is None True ipdb> l 42 validate_order_parameter(order) 43 if order is not None: 44 body["params"] = prepare_order_params(order) 45 response = self._send_request(endpoint, body) 46 results = get_library_contents(response, MUSIC_SHELF) ---> 47 if results is None: ``` Something similar happens with uploaded artists: ``` ipdb> self.client.get_library_upload_artists() [] ``` As I said, getting an uploaded artist individually works fine: ``` ipdb> self.client.get_library_upload_artist("FEmusic_library_privately_owned_artist_detaila_XXXXXXXXXXXXXX") [{'entityId': 't_po_HHHHHHHHHHHHHHH', 'videoId': 'YYYYYYYYYYYYY', 'title': '...... ``` Any idea what is happening here? I have tried to use the latest commit on master branch, but it fails the same way. Using v0.23.0 returns a different error ``` File "/mypath", line 128, in get_songs return self.client.get_library_upload_songs(limit=config["song"]["limit"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/hmypath, line 46, in get_library_upload_songs results = find_object_by_key(nav(response, SINGLE_COLUMN_TAB + SECTION_LIST), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/mypath", line 74, in nav raise err File "/mypath", line 68, in nav root = root[k] ~~~~^^^ KeyError: 'contents' ``` My environment is: - Ubuntu 22.04.1 LTS - YTMusic API v0.24.0 - python 3.11 Thanks a lot.
kerem 2026-02-27 22:08:48 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sigma67 commented on GitHub (Nov 30, 2022):

The mentioned endpoints are working fine for me. Are you sure your credentials haven't expired?

If that's not the case I can try reproducing the issue with your credentials, if you don't mind sending them to ytmusicapi@gmail.com.

<!-- gh-comment-id:1332065368 --> @sigma67 commented on GitHub (Nov 30, 2022): The mentioned endpoints are working fine for me. Are you sure your credentials haven't expired? If that's not the case I can try reproducing the issue with your credentials, if you don't mind sending them to ytmusicapi@gmail.com.
Author
Owner

@rvaquerizor commented on GitHub (Dec 3, 2022):

@sigma67 Thanks a lot for the reply and sorry for my late response.

Are you sure your credentials haven't expired?

In all fairness, I am not 100% sure. In fact, it is true that my credentials expired a while ago, and I created a new headers json file with new ones, but maybe that is not working fine, somehow.

However, if the problem is related to my credentials, then:

  • how is it possible that I get an authenticated client instance successfully every time?
  • how is it possible that I can call get_library_upload_artist method using that authenticated client and get the right result?

The problem only shows when calling get_library_upload_songs and get_library_upload_artists.

Here is a REPL session showing the above:

In [1]: from ytmusicapi import YTMusic

In [2]: client = YTMusic("youtubemusic/config/headers_auth.json")

In [3]: client
Out[3]: <ytmusicapi.ytmusic.YTMusic at 0x7ffa598e2b90>

In [4]: client.get_library_upload_songs(limit=100)
Out[4]: []

In [5]: client.get_library_upload_artists(limit=100)
Out[5]: []

In [8]: client.get_library_upload_artist("FEmusic_library_privately_owned_artist_detaila_po_CIOIo7OKzretmwESA3Vmbw")
Out[8]: 
[{'entityId': 't_po_CIOIo7OKzretmwEQuqXj1f7_____AQ',
  'videoId': 'vwkLZPH6w2A',
  'title': 'Doctor Doctor',
  'duration': '4:03',
  'duration_seconds': 243,
  'artists': [{'name': 'UFO',
    'id': 'FEmusic_library_privately_owned_artist_detaila_po_CIOIo7OKzretmwESA3Vmbw'}],
  'album': None,
  'likeStatus': 'INDIFFERENT',
  'thumbnails': [{'url': 'https://www.gstatic.com/youtube/media/ytm/images/cover_track_default@1200.png?sqp=CPXnx-oF-oaymwEGCDwQPFgB&rs=ALLJMcKG4HoG-nDcHAjjtvKnA1-TsHbplA',
    'width': 60,
    'height': 60},
   {'url': 'https://www.gstatic.com/youtube/media/ytm/images/cover_track_default@1200.png?sqp=CMnnx-oF-oaymwEGCHgQeFgB&rs=ALLJMcJMYVX-njU3_fFWsT7BvREyrfEBFQ',
    'width': 120,
    'height': 120}]}]

Anyway, I suspect that somehow you are right and my problem is a credentials problem.

I will send you my credentials to your private email account ....

Thanks.

<!-- gh-comment-id:1336100776 --> @rvaquerizor commented on GitHub (Dec 3, 2022): @sigma67 Thanks a lot for the reply and sorry for my late response. > Are you sure your credentials haven't expired? In all fairness, I am not 100% sure. In fact, it is true that my credentials expired a while ago, and I created a new headers json file with new ones, but maybe that is not working fine, somehow. However, if the problem is related to my credentials, then: - how is it possible that I get an authenticated client instance successfully every time? - how is it possible that I can call **get_library_upload_artist** method using that authenticated client and get the right result? The problem only shows when calling **get_library_upload_songs** and **get_library_upload_artists**. Here is a REPL session showing the above: ``` In [1]: from ytmusicapi import YTMusic In [2]: client = YTMusic("youtubemusic/config/headers_auth.json") In [3]: client Out[3]: <ytmusicapi.ytmusic.YTMusic at 0x7ffa598e2b90> In [4]: client.get_library_upload_songs(limit=100) Out[4]: [] In [5]: client.get_library_upload_artists(limit=100) Out[5]: [] In [8]: client.get_library_upload_artist("FEmusic_library_privately_owned_artist_detaila_po_CIOIo7OKzretmwESA3Vmbw") Out[8]: [{'entityId': 't_po_CIOIo7OKzretmwEQuqXj1f7_____AQ', 'videoId': 'vwkLZPH6w2A', 'title': 'Doctor Doctor', 'duration': '4:03', 'duration_seconds': 243, 'artists': [{'name': 'UFO', 'id': 'FEmusic_library_privately_owned_artist_detaila_po_CIOIo7OKzretmwESA3Vmbw'}], 'album': None, 'likeStatus': 'INDIFFERENT', 'thumbnails': [{'url': 'https://www.gstatic.com/youtube/media/ytm/images/cover_track_default@1200.png?sqp=CPXnx-oF-oaymwEGCDwQPFgB&rs=ALLJMcKG4HoG-nDcHAjjtvKnA1-TsHbplA', 'width': 60, 'height': 60}, {'url': 'https://www.gstatic.com/youtube/media/ytm/images/cover_track_default@1200.png?sqp=CMnnx-oF-oaymwEGCHgQeFgB&rs=ALLJMcJMYVX-njU3_fFWsT7BvREyrfEBFQ', 'width': 120, 'height': 120}]}] ``` Anyway, I suspect that somehow you are right and my problem is a credentials problem. I will send you my credentials to your private email account .... Thanks.
Author
Owner

@sigma67 commented on GitHub (Dec 5, 2022):

I was able to verify that your credentials are valid and that you are indeed getting an empty list even though you have uploads. Will look into a fix.

<!-- gh-comment-id:1336901860 --> @sigma67 commented on GitHub (Dec 5, 2022): I was able to verify that your credentials are valid and that you are indeed getting an empty list even though you have uploads. Will look into a fix.
Author
Owner

@sigma67 commented on GitHub (Dec 7, 2022):

Can you verify that the fix works for you?

<!-- gh-comment-id:1341252329 --> @sigma67 commented on GitHub (Dec 7, 2022): Can you verify that the fix works for you?
Author
Owner

@rvaquerizor commented on GitHub (Dec 7, 2022):

@sigma67
I have pulled the latest commit on your main branch:
( 0.24.1.dev5+g2344a17 d0ec2bb)
I presume the commit for your fix (02e3289) is a parent of the tip commit above...

And yes, the fix works perfectly.
I have been able to get all songs and artists I have already uploaded to the server.

Thanks a lot for the quick fix.

Is there an ETA for this to be released?

Thanks.

<!-- gh-comment-id:1341427049 --> @rvaquerizor commented on GitHub (Dec 7, 2022): @sigma67 I have pulled the latest commit on your main branch: `( 0.24.1.dev5+g2344a17 d0ec2bb) ` I presume the commit for your fix (02e3289) is a parent of the tip commit above... And yes, the fix works perfectly. I have been able to get all songs and artists I have already uploaded to the server. Thanks a lot for the quick fix. Is there an ETA for this to be released? Thanks.
Author
Owner

@sigma67 commented on GitHub (Jan 15, 2023):

Release is up.

<!-- gh-comment-id:1383186517 --> @sigma67 commented on GitHub (Jan 15, 2023): Release is up.
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#247
No description provided.