Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"get_library_upload_songs" and "get_library_upload_artists" methods fail returning empty list #320

Closed
rvaquerizor opened this issue Nov 30, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@rvaquerizor
Copy link

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.

@sigma67
Copy link
Owner

sigma67 commented 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 [email protected].

@rvaquerizor
Copy link
Author

rvaquerizor commented 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/[email protected]?sqp=CPXnx-oF-oaymwEGCDwQPFgB&rs=ALLJMcKG4HoG-nDcHAjjtvKnA1-TsHbplA',
    'width': 60,
    'height': 60},
   {'url': 'https://www.gstatic.com/youtube/media/ytm/images/[email protected]?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.

@rvaquerizor rvaquerizor changed the title "get_library_upload_songs" and "get_library_upload_songs" methods fail returning empty list "get_library_upload_songs" and "get_library_upload_artists" methods fail returning empty list Dec 3, 2022
@sigma67 sigma67 added the bug Something isn't working label Dec 5, 2022
@sigma67
Copy link
Owner

sigma67 commented 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.

@sigma67
Copy link
Owner

sigma67 commented Dec 7, 2022

Can you verify that the fix works for you?

@rvaquerizor
Copy link
Author

@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.

@sigma67
Copy link
Owner

sigma67 commented Jan 15, 2023

Release is up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants