mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
[reddit] Workaround for 429 by redirecting to old.reddit.com
Closes #1014
This commit is contained in:
parent
bd50a52b0d
commit
a76e2e0f88
1 changed files with 3 additions and 7 deletions
|
@ -49,7 +49,7 @@ def _real_extract(self, url):
|
||||||
|
|
||||||
|
|
||||||
class RedditRIE(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 = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.reddit.com/r/videos/comments/6rrwyj/that_small_heart_attack/',
|
'url': 'https://www.reddit.com/r/videos/comments/6rrwyj/that_small_heart_attack/',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
@ -97,15 +97,11 @@ class RedditRIE(InfoExtractor):
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = self._match_valid_url(url)
|
slug, video_id = self._match_valid_url(url).group('slug', 'id')
|
||||||
url, video_id = mobj.group('url', 'id')
|
|
||||||
|
|
||||||
video_id = self._match_id(url)
|
|
||||||
|
|
||||||
self._set_cookie('reddit.com', '_options', '%7B%22pref_quarantine_optin%22%3A%20true%7D')
|
self._set_cookie('reddit.com', '_options', '%7B%22pref_quarantine_optin%22%3A%20true%7D')
|
||||||
|
|
||||||
data = self._download_json(
|
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']
|
video_url = data['url']
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue