question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can´t download a YT video

See original GitHub issue

Checklist

  • [x ] I’m reporting a broken site support issue
  • [x ] I’ve verified that I’m running youtube-dl version 2021.06.06
  • [ x] I’ve checked that all provided URLs are alive and playable in a browser
  • [ x] I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • [ x] I’ve searched the bugtracker for similar bug reports including closed ones
  • [ x] I’ve read bugs section in FAQ

Verbose log

youtube-dl “https://www.youtube.com/watch?v=p7FCgw_GlWc” -v [debug] System config: [] [debug] User config: [] [debug] Custom config: [] [debug] Command-line args: [u’https://www.youtube.com/watch?v=p7FCgw_GlWc’, u’-v’] [debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8 [debug] youtube-dl version 2021.06.06 [debug] Python version 2.7.18 (CPython) - Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-Ubuntu-20.04-focal [debug] exe versions: ffmpeg 4.2.4, ffprobe 4.2.4 [debug] Proxy map: {} [youtube] p7FCgw_GlWc: Downloading webpage [youtube] p7FCgw_GlWc: Refetching age-gated info webpage WARNING: unable to download video info webpage: HTTP Error 410: Gone Traceback (most recent call last): File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main “main”, fname, loader, pkg_name) File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code exec code in run_globals File “/usr/local/bin/youtube-dl/main.py”, line 19, in <module> File “/usr/local/bin/youtube-dl/youtube_dl/init.py”, line 475, in main File “/usr/local/bin/youtube-dl/youtube_dl/init.py”, line 465, in _real_main File “/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py”, line 2069, in download File “/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py”, line 808, in extract_info File “/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py”, line 815, in wrapper File “/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py”, line 836, in __extract_info File “/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py”, line 534, in extract File “/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py”, line 1503, in _real_extract File “/usr/local/bin/youtube-dl/youtube_dl/compat.py”, line 2644, in compat_parse_qs File “/usr/local/bin/youtube-dl/youtube_dl/compat.py”, line 2614, in _parse_qsl AttributeError: ‘bool’ object has no attribute ‘split’



## Description

Hey, i am trying to download a youtube video (https://www.youtube.com/watch?v=p7FCgw_GlWc). It shows me an "WARNING: unable to download video info webpage: HTTP Error 410: Gone" error, i am not really sure what i am doing wrong. I am running youtube-dl on Windows 11 using WSL. AFAIK, the video is age-restricted, but is public and accessable with my browser - i dont see how that could be a problem.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
dirkfcommented, Nov 21, 2021

This patch back-ports the Android embed client work-around from yt-dlp to achieve the same result:

--- old/youtube-dl/youtube_dl/extractor/youtube.py
+++ new/youtube-dl/youtube_dl/extractor/youtube.py
@@ -283,15 +283,18 @@
     _YT_INITIAL_PLAYER_RESPONSE_RE = r'ytInitialPlayerResponse\s*=\s*({.+?})\s*;'
     _YT_INITIAL_BOUNDARY_RE = r'(?:var\s+meta|</script|\n)'
 
-    def _call_api(self, ep, query, video_id, fatal=True):
+    def _call_api(self, ep, query, video_id, fatal=True, headers=None):
         data = self._DEFAULT_API_DATA.copy()
         data.update(query)
+        real_headers = {'content-type': 'application/json'}
+        if headers:
+            real_headers.update(headers)
 
         return self._download_json(
             'https://www.youtube.com/youtubei/v1/%s' % ep, video_id=video_id,
             note='Downloading API JSON', errnote='Unable to download API page',
             data=json.dumps(data).encode('utf8'), fatal=fatal,
-            headers={'content-type': 'application/json'},
+            headers=real_headers,
             query={'key': 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'})
 
     def _extract_yt_initial_data(self, video_id, webpage):
@@ -1503,26 +1506,28 @@
                 'player', {'videoId': video_id}, video_id)
 
         playability_status = player_response.get('playabilityStatus') or {}
-        if playability_status.get('reason') == 'Sign in to confirm your age':
-            video_info = self._download_webpage(
-                base_url + 'get_video_info', video_id,
-                'Refetching age-gated info webpage',
-                'unable to download video info webpage', query={
-                    'video_id': video_id,
-                    'eurl': 'https://youtube.googleapis.com/v/' + video_id,
-                    'html5': 1,
-                    # See https://github.com/ytdl-org/youtube-dl/issues/29333#issuecomment-864049544
-                    'c': 'TVHTML5',
-                    'cver': '6.20180913',
-                }, fatal=False)
-            if video_info:
-                pr = self._parse_json(
-                    try_get(
-                        compat_parse_qs(video_info),
-                        lambda x: x['player_response'][0], compat_str) or '{}',
-                    video_id, fatal=False)
-                if pr and isinstance(pr, dict):
-                    player_response = pr
+        if (playability_status.get('reason') == 'Sign in to confirm your age'
+            and int_or_none(self._downloader.params.get('age_limit'), default=18) >= 18):
+            self.report_age_confirmation()
+            query = {
+                'playbackContext': {'contentPlaybackContext': {'html5Preference': 'HTML5_PREF_WANTS'}},
+                'contentCheckOk': True,
+                'racyCheckOk': True,
+                'context': {
+                    'client': {'clientName': 'ANDROID', 'clientVersion': '16.20', 'hl': 'en', 'clientScreen': 'EMBED'},
+                    'thirdParty': {'embedUrl': 'https://google.com'},
+                },
+                'videoId': video_id,
+            }
+            headers = {
+                'X-YouTube-Client-Name': '3',
+                'X-YouTube-Client-Version': '16.20',
+                'Origin': 'https://www.youtube.com'
+            }
+            video_info = self._call_api('player', query, video_id, fatal=False, headers=headers)
+            if video_info and isinstance(video_info, dict):
+                player_response = video_info
+                playability_status = player_response.get('playabilityStatus') or {}
 
         trailer_video_id = try_get(
             playability_status,

Then:

$ python -m youtube_dl -F 'https://www.youtube.com/watch?v=p7FCgw_GlWc'
[youtube] p7FCgw_GlWc: Downloading webpage
[youtube] Confirming age
[youtube] p7FCgw_GlWc: Downloading API JSON
[info] Available formats for p7FCgw_GlWc:
format code  extension  resolution note
139          m4a        audio only tiny   48k , m4a_dash container, mp4a.40.5@ 48k (22050Hz), 3.71MiB
249          webm       audio only tiny   51k , webm_dash container, opus @ 51k (48000Hz), 3.89MiB
250          webm       audio only tiny   66k , webm_dash container, opus @ 66k (48000Hz), 5.05MiB
251          webm       audio only tiny  127k , webm_dash container, opus @127k (48000Hz), 9.70MiB
140          m4a        audio only tiny  129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 9.83MiB
160          mp4        256x144    144p   33k , mp4_dash container, avc1.4d400c@  33k, 30fps, video only, 2.53MiB
278          webm       256x144    144p   78k , webm_dash container, vp9@  78k, 30fps, video only, 5.98MiB
394          mp4        256x144    144p   84k , mp4_dash container, av01.0.00M.08@  84k, 30fps, video only, 6.40MiB
133          mp4        426x240    240p   55k , mp4_dash container, avc1.4d4015@  55k, 30fps, video only, 4.23MiB
242          webm       426x240    240p   82k , webm_dash container, vp9@  82k, 30fps, video only, 6.24MiB
395          mp4        426x240    240p  189k , mp4_dash container, av01.0.00M.08@ 189k, 30fps, video only, 14.41MiB
134          mp4        640x360    360p  114k , mp4_dash container, avc1.4d401e@ 114k, 30fps, video only, 8.67MiB
243          webm       640x360    360p  142k , webm_dash container, vp9@ 142k, 30fps, video only, 10.85MiB
396          mp4        640x360    360p  301k , mp4_dash container, av01.0.01M.08@ 301k, 30fps, video only, 22.87MiB
135          mp4        854x480    480p  193k , mp4_dash container, avc1.4d401f@ 193k, 30fps, video only, 14.71MiB
244          webm       854x480    480p  234k , webm_dash container, vp9@ 234k, 30fps, video only, 17.77MiB
397          mp4        854x480    480p  547k , mp4_dash container, av01.0.04M.08@ 547k, 30fps, video only, 41.59MiB
136          mp4        1280x720   720p  452k , mp4_dash container, avc1.4d401f@ 452k, 30fps, video only, 34.36MiB
247          webm       1280x720   720p  470k , webm_dash container, vp9@ 470k, 30fps, video only, 35.71MiB
398          mp4        1280x720   720p 1112k , mp4_dash container, av01.0.05M.08@1112k, 30fps, video only, 84.46MiB
399          mp4        1920x1080  1080p 1759k , mp4_dash container, av01.0.08M.08@1759k, 30fps, video only, 133.61MiB
248          webm       1920x1080  1080p 1767k , webm_dash container, vp9@1767k, 30fps, video only, 134.21MiB
137          mp4        1920x1080  1080p 2850k , mp4_dash container, avc1.640028@2850k, 30fps, video only, 216.45MiB
17           3gp        176x144    144p   68k , mp4v.20.3, 7fps, mp4a.40.2 (22050Hz), 5.22MiB
18           mp4        640x360    360p  509k , avc1.42001E, 30fps, mp4a.40.2 (44100Hz), 38.68MiB
22           mp4        1280x720   720p 2260k , avc1.64001F, 30fps, mp4a.40.2 (44100Hz) (best)
$

Videos like Cr381pDsSsA (Some Girls from Equestria have a …) that reject embedding are not handled.

1reaction
dirkfcommented, Aug 12, 2022

Try the linked PR #31043 which worked when I last tested it.

There is a separate issue #31164 with YT today but it doesn’t affect this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't I download YouTube videos anymore - EaseUS
According to YouTube's Terms and Conditions, users are not allowed to download any videos from YouTube. Rather than download videos, YouTube ...
Read more >
[Problem Solved!] Can't Download YouTube Videos Anymore
Try These Things If You Can't Download Videos from YouTube · Use a third-party YouTube video downloader · Make sure that you are...
Read more >
How to Fix Cannot Download YouTube Video - AceThinker
How to Fix Cannot Download YouTube Video ; Step 1 Install the AceThinker Video Keeper ; Step 2 Download YouTube Videos that cannot...
Read more >
Why I can't download some YouTube videos using ... - Quora
Many download program have quit working because YouTube is changing their encryption. Either the video won't download, or it's corrupted. However, VideoProc ...
Read more >
[2022 Updated] Can't Download YouTube Videos? Try These ...
If you find that you fail to download any YouTube video, it is most likely a result of the outdated download tool. Try...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found