From c77df98b1a477a020a57141464d10c0f4d0fdbc9 Mon Sep 17 00:00:00 2001 From: OMEGA_RAZER <869111+OMEGARAZER@users.noreply.github.com> Date: Mon, 6 Feb 2023 08:51:39 -0500 Subject: [PATCH] [extractor/reddit] Support user posts (#6173) Authored by: OMEGARAZER --- yt_dlp/extractor/reddit.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/reddit.py b/yt_dlp/extractor/reddit.py index 836b3a7ae..9dba3eca8 100644 --- a/yt_dlp/extractor/reddit.py +++ b/yt_dlp/extractor/reddit.py @@ -14,7 +14,7 @@ from ..utils import ( class RedditIE(InfoExtractor): - _VALID_URL = r'https?://(?P[^/]+\.)?reddit(?:media)?\.com/r/(?P[^/]+/comments/(?P[^/?#&]+))' + _VALID_URL = r'https?://(?P[^/]+\.)?reddit(?:media)?\.com/(?P(?:r|user)/[^/]+/comments/(?P[^/?#&]+))' _TESTS = [{ 'url': 'https://www.reddit.com/r/videos/comments/6rrwyj/that_small_heart_attack/', 'info_dict': { @@ -58,6 +58,29 @@ class RedditIE(InfoExtractor): 'age_limit': 0, 'channel_id': 'aww', }, + }, { + # User post + 'url': 'https://www.reddit.com/user/creepyt0es/comments/nip71r/i_plan_to_make_more_stickers_and_prints_check/', + 'info_dict': { + 'id': 'zasobba6wp071', + 'ext': 'mp4', + 'display_id': 'nip71r', + 'title': 'I plan to make more stickers and prints! Check them out on my Etsy! Or get them through my Patreon. Links below.', + 'thumbnail': r're:^https?://.*\.(?:jpg|png)', + 'thumbnails': 'count:5', + 'timestamp': 1621709093, + 'upload_date': '20210522', + 'uploader': 'creepyt0es', + 'duration': 6, + 'like_count': int, + 'dislike_count': int, + 'comment_count': int, + 'age_limit': 0, + 'channel_id': 'u_creepyt0es', + }, + 'params': { + 'skip_download': True, + }, }, { # videos embedded in reddit text post 'url': 'https://www.reddit.com/r/KamenRider/comments/wzqkxp/finale_kamen_rider_revice_episode_50_family_to/', @@ -84,6 +107,7 @@ class RedditIE(InfoExtractor): 'dislike_count': int, 'comment_count': int, 'age_limit': 0, + 'channel_id': 'dumbfuckers_club', }, }, { 'url': 'https://www.reddit.com/r/videos/comments/6rrwyj', @@ -124,10 +148,10 @@ class RedditIE(InfoExtractor): self._set_cookie('.reddit.com', 'reddit_session', self._gen_session_id()) self._set_cookie('.reddit.com', '_options', '%7B%22pref_quarantine_optin%22%3A%20true%7D') - data = self._download_json(f'https://{subdomain}reddit.com/r/{slug}/.json', video_id, fatal=False) + data = self._download_json(f'https://{subdomain}reddit.com/{slug}/.json', video_id, fatal=False) if not data: # Fall back to old.reddit.com in case the requested subdomain fails - data = self._download_json(f'https://old.reddit.com/r/{slug}/.json', video_id) + data = self._download_json(f'https://old.reddit.com/{slug}/.json', video_id) data = data[0]['data']['children'][0]['data'] video_url = data['url']