ytmusicapi icon indicating copy to clipboard operation
ytmusicapi copied to clipboard

get_watch_playlist() fails with 404: Requested entity not found

Open toasterofbread opened this issue 3 years ago • 7 comments

A project I'm working on involving ytmusicapi suddenly stopped working today. Whenever get_watch_playlist is called it fails with the following error regardless of whether the client is authenticated:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/.local/lib/python3.10/site-packages/ytmusicapi/mixins/watch.py", line 120, in get_watch_playlist
    response = self._send_request(endpoint, body)
  File "~/.local/lib/python3.10/site-packages/ytmusicapi/ytmusic.py", line 144, in _send_request
    raise Exception(message + error)
Exception: Server returned HTTP 404: Not Found.
Requested entity was not found.

I've tried multiple valid ids, invalid ids, and using a VPN, none of which seem to make a difference. Other functions like search seem to work fine, and YouTube Music works as usual in a browser.

toasterofbread avatar Sep 19 '22 15:09 toasterofbread

From what I've found the error can be avoided by changing https://github.com/sigma67/ytmusicapi/blob/20b4631c31b65d5d40caf89b5db5fd661e82a979/ytmusicapi/helpers.py#L26 to 1.20220912.01.00 (as found when inspecting traffic generated by the web app).

Since there's a date in the new version string, I wonder whether this may need to be dynamically updated when new versions of the web app are released.

simu avatar Sep 19 '22 15:09 simu

From what I've found the error can be avoided by changing

https://github.com/sigma67/ytmusicapi/blob/20b4631c31b65d5d40caf89b5db5fd661e82a979/ytmusicapi/helpers.py#L26

to 1.20220912.01.00 (as found when inspecting traffic generated by the web app). Since there's a date in the new version string, I wonder whether this may need to be dynamically updated when new versions of the web app are released.

Does this actually work for you? I tried the suggested change, but I still get the same 404 error.

{
   "context": {
      "client": {"clientName": "WEB_REMIX", "clientVersion": "1.20220912.01.00"},
      "user": {},
   }
}

MarvinSchenkel avatar Sep 19 '22 18:09 MarvinSchenkel

Does this actually work for you? I tried the suggested change, but I still get the same 404 error.

Yes, it worked for me (approximately 10 hours ago), however I'm not 100% if that ended up being the only change that I had to make (I'll have to check that tomorrow). Additionally, I also used a fresh cookie copied from the web app today.

simu avatar Sep 19 '22 18:09 simu

Guess what, this morning my get_watch_playlist started working again, even without the change of clientVersion. Did YT Music revert some changes on their side?

MarvinSchenkel avatar Sep 20 '22 06:09 MarvinSchenkel

Might have been some sort of A/B testing? I cannot reproduce the error currently.

We may need to find a way to dynamically get a viable clientVersion if this turns out to be the cause. My current version on the web interface is 1.20220914.01.00.

sigma67 avatar Sep 20 '22 07:09 sigma67

Might have been some sort of A/B testing? I cannot reproduce the error currently.

Looks like it, I can't reproduce it anymore either (side-note: the web app has version 1.20220914.01.00 for me today as well).

Does this actually work for you? I tried the suggested change, but I still get the same 404 error.

Yes, it worked for me (approximately 10 hours ago), however I'm not 100% if that ended up being the only change that I had to make (I'll have to check that tomorrow).

I checked again, the only change I made yesterday (after some trial and error) was setting the clientVersion to the value if found in the web app.

simu avatar Sep 20 '22 11:09 simu

I preemptively changed the version string to the current date, which seems to be working for now. I'd like to avoid having to retrieve or set the version on init, and a fake version seems to work right now.

sigma67 avatar Sep 20 '22 15:09 sigma67

Seems to be resolved for now, can reopen if needed in the future.

sigma67 avatar Oct 01 '22 13:10 sigma67

Amazing! Will wait for the next release to include it in my product!

Op za 1 okt. 2022 om 15:42 schreef sigma67 @.***>

Closed #296 https://github.com/sigma67/ytmusicapi/issues/296 as completed.

— Reply to this email directly, view it on GitHub https://github.com/sigma67/ytmusicapi/issues/296#event-7500446583, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEG2MJYTMWCTRJZ2GHXUMODWBA5VTANCNFSM6AAAAAAQQGPLPI . You are receiving this because you commented.Message ID: @.***>

MarvinSchenkel avatar Oct 01 '22 14:10 MarvinSchenkel