mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 19:52:40 +01:00
[youtube] ultimate age gate fix
This commit is contained in:
parent
ff3c7af428
commit
fb2c9277bc
@ -1742,6 +1742,13 @@ def extract_player_response(player_response, video_id):
|
|||||||
add_dash_mpd_pr(pl_response)
|
add_dash_mpd_pr(pl_response)
|
||||||
return pl_response
|
return pl_response
|
||||||
|
|
||||||
|
def extract_embedded_config(embed_webpage, video_id):
|
||||||
|
embedded_config = self._search_regex(
|
||||||
|
r'setConfig\(({.*})\);',
|
||||||
|
embed_webpage, 'ytInitialData', default=None)
|
||||||
|
if embedded_config:
|
||||||
|
return embedded_config
|
||||||
|
|
||||||
player_response = {}
|
player_response = {}
|
||||||
|
|
||||||
# Get video info
|
# Get video info
|
||||||
@ -1755,8 +1762,17 @@ def extract_player_response(player_response, video_id):
|
|||||||
# this can be viewed without login into Youtube
|
# this can be viewed without login into Youtube
|
||||||
url = proto + '://www.youtube.com/embed/%s' % video_id
|
url = proto + '://www.youtube.com/embed/%s' % video_id
|
||||||
embed_webpage = self._download_webpage(url, video_id, 'Downloading embed webpage')
|
embed_webpage = self._download_webpage(url, video_id, 'Downloading embed webpage')
|
||||||
# check if video is only playable on youtube - if so it requires auth (cookies)
|
ext = extract_embedded_config(embed_webpage, video_id)
|
||||||
if re.search(r'player-unavailable">', embed_webpage) is not None:
|
# playabilityStatus = re.search(r'{\\\"status\\\":\\\"(?P<playabilityStatus>[^\"]+)\\\"', ext)
|
||||||
|
playable_in_embed = re.search(r'{\\\"playableInEmbed\\\":(?P<playableinEmbed>[^\,]+)', ext)
|
||||||
|
if not playable_in_embed:
|
||||||
|
self.to_screen('Could not determine whether playabale in embed for video %s' % video_id)
|
||||||
|
playable_in_embed = ''
|
||||||
|
else:
|
||||||
|
playable_in_embed = playable_in_embed.group('playableinEmbed')
|
||||||
|
# check if video is only playable on youtube in other words not playable in embed - if so it requires auth (cookies)
|
||||||
|
# if re.search(r'player-unavailable">', embed_webpage) is not None:
|
||||||
|
if playable_in_embed == 'false':
|
||||||
'''
|
'''
|
||||||
# TODO apply this patch when Support for Python 2.6(!) and above drops
|
# TODO apply this patch when Support for Python 2.6(!) and above drops
|
||||||
if ({'VISITOR_INFO1_LIVE', 'HSID', 'SSID', 'SID'} <= cookie_keys
|
if ({'VISITOR_INFO1_LIVE', 'HSID', 'SSID', 'SID'} <= cookie_keys
|
||||||
|
Loading…
Reference in New Issue
Block a user