aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbashonly <88596187+bashonly@users.noreply.github.com>2022-11-17 19:09:40 +0000
committerGitHub <noreply@github.com>2022-11-17 19:09:40 +0000
commitf96a3fb7d3cbeb2b63c2eafcc14b359f37ff3078 (patch)
tree64db72f4b8f45152564fcb56a703563555ff3b0b
parentbc87dac75f289581bb2cd98500015c4d6a9027de (diff)
downloadhypervideo-pre-f96a3fb7d3cbeb2b63c2eafcc14b359f37ff3078.tar.lz
hypervideo-pre-f96a3fb7d3cbeb2b63c2eafcc14b359f37ff3078.tar.xz
hypervideo-pre-f96a3fb7d3cbeb2b63c2eafcc14b359f37ff3078.zip
[extractor/redgifs] Fix bug in 8c188d5d09177ed213a05c900d3523867c5897fd (#5559)
-rw-r--r--yt_dlp/extractor/redgifs.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/yt_dlp/extractor/redgifs.py b/yt_dlp/extractor/redgifs.py
index f688d1e63..098fb8185 100644
--- a/yt_dlp/extractor/redgifs.py
+++ b/yt_dlp/extractor/redgifs.py
@@ -72,7 +72,7 @@ class RedGifsBaseInfoExtractor(InfoExtractor):
self._API_HEADERS['authorization'] = f'Bearer {auth["token"]}'
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:
self._fetch_oauth_token(video_id)
try:
@@ -82,8 +82,9 @@ class RedGifsBaseInfoExtractor(InfoExtractor):
f'https://api.redgifs.com/v2/{ep}', video_id, headers=headers, *args, **kwargs)
break
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
+ continue
raise
if 'error' in data: