ur1katz / casttube

YouTube Chromecast API
MIT License
53 stars 10 forks source link

Need to set HTTP Length header on post requests #13

Open lanrat opened 2 years ago

lanrat commented 2 years ago

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
alexdelorenzo commented 1 year ago

Running into this error, as well.