summary refs log tree commit diff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2020-12-01 00:49:03 +0700
committerSergey M․ <dstftw@gmail.com>2020-12-01 00:49:26 +0700
commit59d63d8d4aa82c7b1472d5b6a0f9f4e9c2893212 (patch)
tree8ee067f94d03f9e1236880dbae338b718ebdcec1
parentcfeba5d17f5f621b129571213e7034c44c719e76 (diff)
downloadyoutube-dl-59d63d8d4aa82c7b1472d5b6a0f9f4e9c2893212.tar.gz
youtube-dl-59d63d8d4aa82c7b1472d5b6a0f9f4e9c2893212.tar.xz
youtube-dl-59d63d8d4aa82c7b1472d5b6a0f9f4e9c2893212.zip
[youtube] Improve age-gated videos extraction (closes #27259)
-rw-r--r--youtube_dl/extractor/youtube.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 4616ac53d..6fdc379cd 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -602,7 +602,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
                 'description': 'SUBSCRIBE: http://www.youtube.com/saturninefilms\n\nEven Obama has taken a stand against freedom on this issue: http://www.huffingtonpost.com/2010/09/09/obama-gma-interview-quran_n_710282.html',
             }
         },
-        # Normal age-gate video (No vevo, embed allowed)
+        # Normal age-gate video (No vevo, embed allowed), available via embed page
         {
             'url': 'https://youtube.com/watch?v=HtVdAasjOgU',
             'info_dict': {
@@ -618,6 +618,12 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
                 'age_limit': 18,
             },
         },
+        {
+            # Age-gated video only available with authentication (unavailable
+            # via embed page workaround)
+            'url': 'XgnwCQzjau8',
+            'only_matching': True,
+        },
         # video_info is None (https://github.com/ytdl-org/youtube-dl/issues/4421)
         # YouTube Red ad is not captured for creator
         {
@@ -1637,8 +1643,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
         # Get video info
         video_info = {}
         embed_webpage = None
-        if (self._og_search_property('restrictions:age', video_webpage, default=None) == '18+'
-                or re.search(r'player-age-gate-content">', video_webpage) is not None):
+
+        if re.search(r'["\']status["\']\s*:\s*["\']LOGIN_REQUIRED', video_webpage) is not None:
             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