mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 02:42:30 +00:00
[extractor/redgifs] Fix bug in 8c188d5d09
(#5559)
This commit is contained in:
parent
bc87dac75f
commit
f96a3fb7d3
@ -72,7 +72,7 @@ def _fetch_oauth_token(self, video_id):
|
|||||||
self._API_HEADERS['authorization'] = f'Bearer {auth["token"]}'
|
self._API_HEADERS['authorization'] = f'Bearer {auth["token"]}'
|
||||||
|
|
||||||
def _call_api(self, ep, video_id, *args, **kwargs):
|
def _call_api(self, ep, video_id, *args, **kwargs):
|
||||||
for attempt in range(2):
|
for first_attempt in True, False:
|
||||||
if 'authorization' not in self._API_HEADERS:
|
if 'authorization' not in self._API_HEADERS:
|
||||||
self._fetch_oauth_token(video_id)
|
self._fetch_oauth_token(video_id)
|
||||||
try:
|
try:
|
||||||
@ -82,8 +82,9 @@ def _call_api(self, ep, video_id, *args, **kwargs):
|
|||||||
f'https://api.redgifs.com/v2/{ep}', video_id, headers=headers, *args, **kwargs)
|
f'https://api.redgifs.com/v2/{ep}', video_id, headers=headers, *args, **kwargs)
|
||||||
break
|
break
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if not attempt and isinstance(e.cause, urllib.error.HTTPError) and e.cause.code == 401:
|
if first_attempt and isinstance(e.cause, urllib.error.HTTPError) and e.cause.code == 401:
|
||||||
del self._API_HEADERS['authorization'] # refresh the token
|
del self._API_HEADERS['authorization'] # refresh the token
|
||||||
|
continue
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if 'error' in data:
|
if 'error' in data:
|
||||||
|
Loading…
Reference in New Issue
Block a user