casttube icon indicating copy to clipboard operation
casttube copied to clipboard

Need to set HTTP Length header on post requests

Open lanrat opened this issue 1 year ago • 1 comments

Currently _get_lounge_id() is failing with an HTTP 411 response code because the remote API is requiring that the post request have the HTTP Length header set.

_do_post() should be updated to set the correct length.

Stacktrace:

  File "/usr/local/lib/python3.10/site-packages/casttube/YouTubeSession.py", line 89, in play_video
    self._start_session()
  File "/usr/local/lib/python3.10/site-packages/casttube/YouTubeSession.py", line 160, in _start_session
    self._get_lounge_id()
  File "/usr/local/lib/python3.10/site-packages/casttube/YouTubeSession.py", line 169, in _get_lounge_id
    response = self._do_post(LOUNGE_TOKEN_URL, data=data)
  File "/usr/local/lib/python3.10/site-packages/casttube/YouTubeSession.py", line 263, in _do_post
    response.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 411 Client Error: Length Required for url: https://www.youtube.com/api/lounge/pairing/get_lounge_token_batch

lanrat avatar Aug 05 '22 18:08 lanrat

Running into this error, as well.

alexdelorenzo avatar Feb 11 '23 12:02 alexdelorenzo