Repository: ytdl-org/youtube-dl

Issue:
[YouTube] ERROR: Unable to extract age gate player URL
Getting that error when trying to download this video: `http://www.youtube.com/watch?v=6kLq3WMV1nU`

```
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['--verbose', 'http://www.youtube.com/watch?v=6kLq3WMV1nU']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2014.11.04
[debug] Python version 2.6.6 - Linux-3.10.23-xxxx-std-ipv6-64-x86_64-with-centos-6.5-Final
[debug] exe versions: ffmpeg 0.6.5, ffprobe 0.6.5
[debug] Proxy map: {}
[youtube] Confirming age
[youtube] 6kLq3WMV1nU: Downloading webpage
[youtube] 6kLq3WMV1nU: Downloading video info webpage
[youtube] 6kLq3WMV1nU: Refetching age-gated info webpage
[youtube] 6kLq3WMV1nU: Extracting video information
ERROR: Unable to extract age gate player URL; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.
Traceback (most recent call last):
  File "./youtube-link/youtube_dl/extractor/youtube.py", line 841, in _real_extract
    raise ValueError('Could not find vevo ID')
ValueError: Could not find vevo ID
Traceback (most recent call last):
  File "./youtube-link/youtube_dl/YoutubeDL.py", line 536, in extract_info
    ie_result = ie.extract(url)
  File "./youtube-link/youtube_dl/extractor/common.py", line 199, in extract
    return self._real_extract(url)
  File "./youtube-link/youtube_dl/extractor/youtube.py", line 909, in _real_extract
    video_webpage, 'age gate player URL')
  File "./youtube-link/youtube_dl/extractor/common.py", line 436, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
RegexNotFoundError: Unable to extract age gate player URL; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.
```



Discussion:
It seems YouTube does not include STS parameter in the webpage anymore. So it is missing always and for age gated videos with ciphered signatures you will get response 403: Forbidden.
Here is an example video: http://www.youtube.com/watch?v=07FYdnEawAQ

Are there any workarounds or quick fixes for this?

Here are some more URLs where this error occurs:
`http://www.youtube.com/watch?v=2w02QxQZGQc`
`http://www.youtube.com/watch?v=TjpKGcnEa80`
`http://www.youtube.com/watch?v=0GflZLELubQ`


Resolving patch:
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -766,11 +766,13 @@ def _real_extract(self, url):
             age_gate = True
             # We simulate the access to the video from www.youtube.com/v/{video_id}
             # this can be viewed without login into Youtube
+            url = proto + '://www.youtube.com/embed/%s' % video_id
+            embed_webpage = self._download_webpage(url, video_id, 'Downloading embed webpage')
             data = compat_urllib_parse.urlencode({
                 'video_id': video_id,
                 'eurl': 'https://youtube.googleapis.com/v/' + video_id,
                 'sts': self._search_regex(
-                    r'"sts"\s*:\s*(\d+)', video_webpage, 'sts', default=''),
+                    r'"sts"\s*:\s*(\d+)', embed_webpage, 'sts', default=''),
             })
             video_info_url = proto + '://www.youtube.com/get_video_info?' + data
             video_info_webpage = self._download_webpage(
@@ -968,11 +970,10 @@ def _map_to_format_list(urlmap):
                 elif 's' in url_data:
                     encrypted_sig = url_data['s'][0]
 
-                    if not age_gate:
-                        jsplayer_url_json = self._search_regex(
-                            r'"assets":.+?"js":\s*("[^"]+")',
-                            video_webpage, 'JS player URL')
-                        player_url = json.loads(jsplayer_url_json)
+                    jsplayer_url_json = self._search_regex(
+                        r'"assets":.+?"js":\s*("[^"]+")',
+                        embed_webpage if age_gate else video_webpage, 'JS player URL')
+                    player_url = json.loads(jsplayer_url_json)
                     if player_url is None:
                         player_url_json = self._search_regex(
                             r'ytplayer\.config.*?"url"\s*:\s*("[^"]+")',


Test patch: