aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-09-22 19:50:24 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-09-22 19:51:57 +0530
commita76e2e0f8898c06939b6a123fa863ab8876cfa20 (patch)
tree3c27b605f38d6615675b0d67e2338448c529f6a7
parentbd50a52b0d7247cdbf205eb851ce33ae4b89c516 (diff)
downloadhypervideo-pre-a76e2e0f8898c06939b6a123fa863ab8876cfa20.tar.lz
hypervideo-pre-a76e2e0f8898c06939b6a123fa863ab8876cfa20.tar.xz
hypervideo-pre-a76e2e0f8898c06939b6a123fa863ab8876cfa20.zip
[reddit] Workaround for 429 by redirecting to old.reddit.com
Closes #1014
-rw-r--r--yt_dlp/extractor/reddit.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/yt_dlp/extractor/reddit.py b/yt_dlp/extractor/reddit.py
index 638f2b6a8..8e1463d5b 100644
--- a/yt_dlp/extractor/reddit.py
+++ b/yt_dlp/extractor/reddit.py
@@ -49,7 +49,7 @@ class RedditIE(InfoExtractor):
class RedditRIE(InfoExtractor):
- _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?reddit\.com/r/[^/]+/comments/(?P<id>[^/?#&]+))'
+ _VALID_URL = r'https?://(?:[^/]+\.)?reddit\.com/r/(?P<slug>[^/]+/comments/(?P<id>[^/?#&]+))'
_TESTS = [{
'url': 'https://www.reddit.com/r/videos/comments/6rrwyj/that_small_heart_attack/',
'info_dict': {
@@ -97,15 +97,11 @@ class RedditRIE(InfoExtractor):
}]
def _real_extract(self, url):
- mobj = self._match_valid_url(url)
- url, video_id = mobj.group('url', 'id')
-
- video_id = self._match_id(url)
+ slug, video_id = self._match_valid_url(url).group('slug', 'id')
self._set_cookie('reddit.com', '_options', '%7B%22pref_quarantine_optin%22%3A%20true%7D')
-
data = self._download_json(
- url + '/.json', video_id)[0]['data']['children'][0]['data']
+ f'https://old.reddit.com/r/{slug}/.json', video_id)[0]['data']['children'][0]['data']
video_url = data['url']