[youtube] fix for age-restricted videos, which do not contain ytplayer.config (or html5player) on web page

This commit is contained in:
Mort Yao 2016-03-05 19:43:17 +01:00
parent 511098e71f
commit 6c2c29f724

View File

@ -152,8 +152,11 @@ class YouTube(VideoExtractor):
# Parse video page (for DASH)
video_page = get_content('https://www.youtube.com/watch?v=%s' % self.vid)
ytplayer_config = json.loads(re.search('ytplayer.config\s*=\s*([^\n]+?});', video_page).group(1))
self.html5player = 'https:' + ytplayer_config['assets']['js']
try:
ytplayer_config = json.loads(re.search('ytplayer.config\s*=\s*([^\n]+?});', video_page).group(1))
self.html5player = 'https:' + ytplayer_config['assets']['js']
except:
self.html5player = None
else:
# Parse video page instead
@ -294,6 +297,7 @@ class YouTube(VideoExtractor):
}
except:
# VEVO
if not self.html5player: return
self.js = get_content(self.html5player)
if 'adaptive_fmts' in ytplayer_config['args']:
streams = [dict([(i.split('=')[0],