From 8e765755f7f4909e1b535e61b7376b2d66e1ba6a Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:15:04 -0600 Subject: [PATCH] [ie/vimeo] Fix API headers (#9125) Closes #9124 Authored by: bashonly --- yt_dlp/extractor/vimeo.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/vimeo.py b/yt_dlp/extractor/vimeo.py index e5e8144bb..208e11184 100644 --- a/yt_dlp/extractor/vimeo.py +++ b/yt_dlp/extractor/vimeo.py @@ -269,7 +269,7 @@ def _extract_original_format(self, url, video_id, unlisted_hash=None): 'https://vimeo.com/_rv/viewer', video_id, note='Downloading jwt token', fatal=False) or {} if not jwt_response.get('jwt'): return - headers = {'Authorization': 'jwt %s' % jwt_response['jwt']} + headers = {'Authorization': 'jwt %s' % jwt_response['jwt'], 'Accept': 'application/json'} original_response = self._download_json( f'https://api.vimeo.com/videos/{video_id}', video_id, headers=headers, fatal=False, expected_status=(403, 404)) or {} @@ -751,6 +751,7 @@ def _extract_from_api(self, video_id, unlisted_hash=None): video = self._download_json( api_url, video_id, headers={ 'Authorization': 'jwt ' + token, + 'Accept': 'application/json', }, query={ 'fields': 'config_url,created_time,description,license,metadata.connections.comments.total,metadata.connections.likes.total,release_time,stats.plays', }) @@ -785,7 +786,7 @@ def _try_album_password(self, url): jwt = viewer['jwt'] album = self._download_json( 'https://api.vimeo.com/albums/' + album_id, - album_id, headers={'Authorization': 'jwt ' + jwt}, + album_id, headers={'Authorization': 'jwt ' + jwt, 'Accept': 'application/json'}, query={'fields': 'description,name,privacy'}) if try_get(album, lambda x: x['privacy']['view']) == 'password': password = self.get_param('videopassword') @@ -1147,10 +1148,12 @@ def _fetch_page(self, album_id, authorization, hashed_pass, page): 'https://api.vimeo.com/albums/%s/videos' % album_id, album_id, 'Downloading page %d' % api_page, query=query, headers={ 'Authorization': 'jwt ' + authorization, + 'Accept': 'application/json', })['data'] except ExtractorError as e: if isinstance(e.cause, HTTPError) and e.cause.status == 400: return + raise for video in videos: link = video.get('link') if not link: @@ -1171,7 +1174,7 @@ def _real_extract(self, url): jwt = viewer['jwt'] album = self._download_json( 'https://api.vimeo.com/albums/' + album_id, - album_id, headers={'Authorization': 'jwt ' + jwt}, + album_id, headers={'Authorization': 'jwt ' + jwt, 'Accept': 'application/json'}, query={'fields': 'description,name,privacy'}) hashed_pass = None if try_get(album, lambda x: x['privacy']['view']) == 'password':