Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reddit downloads don't work when you use shortlinks #6665

Closed
9 of 11 tasks
TimothyRichardGreen opened this issue Mar 28, 2023 · 1 comment · Fixed by #6825
Closed
9 of 11 tasks

Reddit downloads don't work when you use shortlinks #6665

TimothyRichardGreen opened this issue Mar 28, 2023 · 1 comment · Fixed by #6825
Labels
good first issue Good for new devs patch-available There is patch available that should fix this issue. Someone needs to make a PR with it site-bug Issue with a specific website

Comments

@TimothyRichardGreen
Copy link

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

Ireland

Provide a description that is worded well enough to be understood

Reddit's shortlinks (at redd.it) probably don't need special-casing, as they issue a normal HTTP 301 redirect response, but the page to which they redirect is not a page that yt-dlp knows how to cope with. In a browser, Reddit loads the page and then (I think) uses history.pushState() to update the URL to the normal one that yt-dlp expects.

Since the page initially loaded does contain the video, I imagine that it would be a relatively minor tweak to yt-dlp to support these URLs.

(Te example video provided is safe for work, by the way.)

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

[debug] Command-line config: ['https://redd.it/124pp33', '-vU']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.03.04 [392389b7d] (zip)
[debug] Python 3.8.10 (CPython x86_64 64bit) - Linux-5.4.0-144-generic-x86_64-with-glibc2.29 (OpenSSL 1.1.1f  31 Mar 2020, glibc 2.31)
[debug] exe versions: ffmpeg 4.2.7, ffprobe 4.2.7
[debug] Optional libraries: Crypto-broken 2.6.1, certifi-2019.11.28, secretstorage-2.3.1, sqlite3-2.6.0
[debug] Proxy map: {}
[debug] Loaded 1786 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.03.04, Current version: stable@2023.03.04
Current Build Hash: 91cad9f121c1f6f0a81b747415c46ecba0ff331ed38cc6433040b4ac7b6e15ca
yt-dlp is up to date (stable@2023.03.04)
[generic] Extracting URL: https://redd.it/124pp33
[generic] 124pp33: Downloading webpage
[redirect] Following redirect to https://www.reddit.com/comments/124pp33
[generic] Extracting URL: https://www.reddit.com/comments/124pp33
[generic] 124pp33: Downloading webpage
WARNING: [generic] Falling back on generic information extractor
[generic] 124pp33: Extracting information
[debug] Looking for embeds
ERROR: Unsupported URL: https://www.reddit.com/comments/124pp33
Traceback (most recent call last):
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 1518, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 1594, in __extract_info
    ie_result = ie.extract(url)
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 694, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/generic.py", line 2510, in _real_extract
    raise UnsupportedError(url)
yt_dlp.utils.UnsupportedError: Unsupported URL: https://www.reddit.com/comments/124pp33
@TimothyRichardGreen TimothyRichardGreen added site-bug Issue with a specific website triage Untriaged issue labels Mar 28, 2023
@bashonly
Copy link
Member

since https://redd.it/124pp33 redirects to https://www.reddit.com/comments/124pp33, I think this is all we need to do:

diff --git a/yt_dlp/extractor/reddit.py b/yt_dlp/extractor/reddit.py
index 9dba3eca8..4aa935ac2 100644
--- a/yt_dlp/extractor/reddit.py
+++ b/yt_dlp/extractor/reddit.py
@@ -14,7 +14,7 @@
 
 
 class RedditIE(InfoExtractor):
-    _VALID_URL = r'https?://(?P<subdomain>[^/]+\.)?reddit(?:media)?\.com/(?P<slug>(?:r|user)/[^/]+/comments/(?P<id>[^/?#&]+))'
+    _VALID_URL = r'https?://(?P<subdomain>[^/]+\.)?reddit(?:media)?\.com/(?P<slug>(?:(?:r|user)/[^/]+/)?comments/(?P<id>[^/?#&]+))'
     _TESTS = [{
         'url': 'https://www.reddit.com/r/videos/comments/6rrwyj/that_small_heart_attack/',
         'info_dict': {
$ yt-dlp -F "https://redd.it/124pp33"
[generic] Extracting URL: https://redd.it/124pp33
[generic] 124pp33: Downloading webpage
[redirect] Following redirect to https://www.reddit.com/comments/124pp33
[Reddit] Extracting URL: https://www.reddit.com/comments/124pp33
[Reddit] 124pp33: Downloading JSON metadata
[Reddit] 124pp33: Downloading m3u8 information
[Reddit] 124pp33: Downloading MPD manifest
[info] Available formats for antsenjc2jqa1:
ID                  EXT RESOLUTION FPS │   FILESIZE  TBR PROTO │ VCODEC       VBR ACODEC      ABR ASR MORE INFO
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
hls-2-audio_0       mp4 audio only     │                 m3u8  │ audio only       unknown             audio 0
hls-3-audio_0       mp4 audio only     │                 m3u8  │ audio only       unknown             audio 0
dash-audio_0_130140 m4a audio only     │ ~276.55KiB 130k https │ audio only       mp4a.40.2  130k 48k DASH audio, m4a_dash
dash-video_254485   mp4 122x220     30 │ ~540.78KiB 254k https │ avc1.4D401E 254k video only          DASH video, mp4_dash
dash-video_612003   mp4 132x240     30 │ ~  1.27MiB 612k https │ avc1.4D401E 612k video only          DASH video, mp4_dash
hls-354             mp4 158x288        │ ~752.25KiB 354k m3u8  │ avc1.42c01e 354k video only
hls-450             mp4 158x288        │ ~956.25KiB 450k m3u8  │ avc1.42c01e 450k video only
hls-560             mp4 176x320        │ ~  1.16MiB 560k m3u8  │ avc1.42c01e 560k video only
hls-656             mp4 176x320        │ ~  1.36MiB 656k m3u8  │ avc1.42c01e 656k video only
fallback            mp4 198x360        │ ~  1.66MiB 800k https │ h264        800k video only          DASH video, mp4_dash
dash-video_816954   mp4 198x360     30 │ ~  1.70MiB 817k https │ avc1.4D401E 817k video only          DASH video, mp4_dash

@bashonly bashonly added good first issue Good for new devs patch-available There is patch available that should fix this issue. Someone needs to make a PR with it and removed triage Untriaged issue labels Mar 28, 2023
bashonly added a commit that referenced this issue Apr 16, 2023
aalsuwaidi pushed a commit to aalsuwaidi/yt-dlp that referenced this issue Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for new devs patch-available There is patch available that should fix this issue. Someone needs to make a PR with it site-bug Issue with a specific website
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants