Commit 5cc47c2f authored by Lauren N. Liberda's avatar Lauren N. Liberda Committed by Dominika Liberda
Browse files

[youtube] fix age gate for *some* videos

parent a9e6daf0
......@@ -1441,29 +1441,32 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if (self._og_search_property('restrictions:age', video_webpage, default=None) == '18+'
or'player-age-gate-content">', video_webpage) is not None):
age_gate = True
# We simulate the access to the video from{video_id}
# this can be viewed without login into Youtube
data = compat_urllib_parse_urlencode({
'video_id': video_id,
'eurl': '' + video_id,
'html5': 1,
'c': 'TVHTML5',
'cver': '6.20180913',
video_info_url = proto + '://' + data
video_info_webpage = self._download_webpage(
video_info_url, video_id,
note='Downloading age-gated video info',
yti1_player = self._download_webpage(
proto + '://', video_id,
'User-Agent': 'Mozilla/5.0 (SMART-TV; Linux; Tizen 4.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.0 Safari/537.36',
'Content-Type': 'application/json',
'X-Goog-Api-Key': self._YOUTUBE_API_KEY,
'context': {
'client': {
'clientName': 'WEB',
'clientVersion': '2.20210721.00.00',
'clientScreen': 'EMBED',
'videoId': video_id,
note='Downloading age-gated player info',
errnote='unable to download video info')
except ExtractorError:
video_info_webpage = None
if video_info_webpage:
video_info = compat_parse_qs(video_info_webpage)
pl_response = video_info.get('player_response', [None])[0]
player_response = extract_player_response(pl_response, video_id)
yti1_player = None
if yti1_player:
player_response = extract_player_response(yti1_player, video_id)
view_count = extract_view_count(video_info)
view_count = extract_view_count(video_id)
age_gate = False
# Try looking directly into the video webpage
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment