[youtube] Fix age gate content detection (#26100) (closes #26152, closes #26311,...
authorrandom-nick <random-nick@email.com>
Sun, 6 Sep 2020 04:44:53 +0000 (04:44 +0000)
committerGitHub <noreply@github.com>
Sun, 6 Sep 2020 04:44:53 +0000 (11:44 +0700)
youtube_dl/extractor/youtube.py

index 6611caf062295c01408e63a166da34b3d9aca4a0..6ae2e58c17651e4d3928d734543775c0736f7502 100644 (file)
@@ -1825,7 +1825,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
         # Get video info
         video_info = {}
         embed_webpage = None
-        if re.search(r'player-age-gate-content">', video_webpage) is not 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):
             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