[ie/vimeo] Fix API headers (#9125)

Closes #9124
Authored by: bashonly
This commit is contained in:
bashonly 2024-02-02 15:15:04 -06:00 committed by GitHub
parent ffa017cfc5
commit 8e765755f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -269,7 +269,7 @@ class VimeoBaseInfoExtractor(InfoExtractor):
'https://vimeo.com/_rv/viewer', video_id, note='Downloading jwt token', fatal=False) or {} 'https://vimeo.com/_rv/viewer', video_id, note='Downloading jwt token', fatal=False) or {}
if not jwt_response.get('jwt'): if not jwt_response.get('jwt'):
return return
headers = {'Authorization': 'jwt %s' % jwt_response['jwt']} headers = {'Authorization': 'jwt %s' % jwt_response['jwt'], 'Accept': 'application/json'}
original_response = self._download_json( original_response = self._download_json(
f'https://api.vimeo.com/videos/{video_id}', video_id, f'https://api.vimeo.com/videos/{video_id}', video_id,
headers=headers, fatal=False, expected_status=(403, 404)) or {} headers=headers, fatal=False, expected_status=(403, 404)) or {}
@ -751,6 +751,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
video = self._download_json( video = self._download_json(
api_url, video_id, headers={ api_url, video_id, headers={
'Authorization': 'jwt ' + token, 'Authorization': 'jwt ' + token,
'Accept': 'application/json',
}, query={ }, query={
'fields': 'config_url,created_time,description,license,metadata.connections.comments.total,metadata.connections.likes.total,release_time,stats.plays', 'fields': 'config_url,created_time,description,license,metadata.connections.comments.total,metadata.connections.likes.total,release_time,stats.plays',
}) })
@ -785,7 +786,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
jwt = viewer['jwt'] jwt = viewer['jwt']
album = self._download_json( album = self._download_json(
'https://api.vimeo.com/albums/' + album_id, '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'}) query={'fields': 'description,name,privacy'})
if try_get(album, lambda x: x['privacy']['view']) == 'password': if try_get(album, lambda x: x['privacy']['view']) == 'password':
password = self.get_param('videopassword') password = self.get_param('videopassword')
@ -1147,10 +1148,12 @@ class VimeoAlbumIE(VimeoBaseInfoExtractor):
'https://api.vimeo.com/albums/%s/videos' % album_id, 'https://api.vimeo.com/albums/%s/videos' % album_id,
album_id, 'Downloading page %d' % api_page, query=query, headers={ album_id, 'Downloading page %d' % api_page, query=query, headers={
'Authorization': 'jwt ' + authorization, 'Authorization': 'jwt ' + authorization,
'Accept': 'application/json',
})['data'] })['data']
except ExtractorError as e: except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status == 400: if isinstance(e.cause, HTTPError) and e.cause.status == 400:
return return
raise
for video in videos: for video in videos:
link = video.get('link') link = video.get('link')
if not link: if not link:
@ -1171,7 +1174,7 @@ class VimeoAlbumIE(VimeoBaseInfoExtractor):
jwt = viewer['jwt'] jwt = viewer['jwt']
album = self._download_json( album = self._download_json(
'https://api.vimeo.com/albums/' + album_id, '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'}) query={'fields': 'description,name,privacy'})
hashed_pass = None hashed_pass = None
if try_get(album, lambda x: x['privacy']['view']) == 'password': if try_get(album, lambda x: x['privacy']['view']) == 'password':