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
YTMusic responses are unreliable for get_library_songs and get_playlist #52
Comments
I've noticed this issue as well since tests were failing randomly. I attempted to fix it in 90bc753. It might not be a fix if the API result skips songs randomly, in that case those would be missing from the response. In your experience, do invalid responses return songs in the correct order without skips? Or are songs randomly missing in between? To be honest I don't really like the option of implementing retry logic for a server-side issue, as it might become obsolete in the near future. I suggest we wait another month to see if the issue gets resolved by YouTube. If this is not the case, I'll go ahead and merge #53. |
Yes, from my observation, API skips songs randomly and fix from 90bc753 is not enough.
That's completely fine for me. I know that "retry" solution is not very elegant, but unfortunately the problem exists since I moved from GPM so it's been at least a few months already. I kinda lost my patience and decided to workaround it with my PR. Although I agree with you, that proper fix should be on Youtube's server, so let's give them one more month. |
I think this is happening to getHistory() as well! |
I use the ytmusic.get_library_upload_songs(50000) call and did not notice any problems so far. I have about 23000 songs in my library and they are all returned except 2. Have to figure out why 2 are missing. |
It's been almost a month with no updates from YouTube's side. I suggest we merge this PR, however I want to request two changes if possible.
The reasoning for 2) is that the changes from this PR doubled the average execution time for me (based on The default should be False imo, since the objective of the API is to replicate the web client as closely as possible, which also exhibits this odd behavior. Therefore, it would be an optional feature of ytmusicapi, which validates responses for the user to ensure the response is correct. What do you think? |
In the original issue, you also noted that |
Yes, indeed, it seems that Unfortunately for |
I updated my PR(#53) with requested changes, please take a look. |
Thanks for updating the PR! I did some rather extensive testing with the changes and ran (edit: I did some more tests and found 1 or 2 continuations where it worked after 2 or 3 tries (after >15 function calls with 11 continuations each). I believe the performance penalty isn't worth the additional 2 retries). Check this log:
Here are the debug changes in utils.py l.104: print(len(parsed_object['parsed']))
while not validate_func(parsed_object) and retry_counter < max_retries:
response = request_func(request_additional_params)
parsed_object = parse_func(response)
print(len(parsed_object['parsed']))
retry_counter += 1
print("retries: " + str(retry_counter)) |
I also found some isolated instances where the key We should catch that in both |
After some more tests I decided to leave the retries at 3, as the number of retries to success seems to vary a lot depending on time of day and account used. It also seems that the API "warms up" to your requests. For example, if you repeat the same call ( Will merge this PR shortly with the bugfix mentioned in the previous comment. |
Always keep response with most results for retries
Regarding the error with And regarding I set the |
Hi, I'm curious. Are you still using this functionality? I feel like the API has gotten a lot more reliable and the code to achieve this is pretty messy. If it's not being used I'd rather remove it. |
Still use this in my project |
Alright, good to know. |
In my project I am using ytmusicapi to fetch full content of the user's library and save it in csv file. Then I can use these csv files to compare changes in my library or find songs removed from youtube etc.
Unfortunately currently it's very unreliable.
For example: In my library currently I have 2040 songs. To get the library songs I call the api with high limit:
Everytime I send that request, the number of returned songs is different, it varies between 1800-2035 songs.
I know that the problem is in YTM itself, because I observed the same problem on the web client and it hasn't been fixed on their side for months. YTM should return library songs in chunks containing 25 items, but very often it's less than 25.
In the end, on average, at least 10% of my library is missing, making my scripts kinda useless. The same problem occurs for
get_playlist
method.The text was updated successfully, but these errors were encountered: