mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 00:33:58 +03:00
[youtube] fix for age-restricted videos, which do not contain ytplayer.config (or html5player) on web page
This commit is contained in:
parent
511098e71f
commit
6c2c29f724
@ -152,8 +152,11 @@ class YouTube(VideoExtractor):
|
|||||||
|
|
||||||
# Parse video page (for DASH)
|
# Parse video page (for DASH)
|
||||||
video_page = get_content('https://www.youtube.com/watch?v=%s' % self.vid)
|
video_page = get_content('https://www.youtube.com/watch?v=%s' % self.vid)
|
||||||
|
try:
|
||||||
ytplayer_config = json.loads(re.search('ytplayer.config\s*=\s*([^\n]+?});', video_page).group(1))
|
ytplayer_config = json.loads(re.search('ytplayer.config\s*=\s*([^\n]+?});', video_page).group(1))
|
||||||
self.html5player = 'https:' + ytplayer_config['assets']['js']
|
self.html5player = 'https:' + ytplayer_config['assets']['js']
|
||||||
|
except:
|
||||||
|
self.html5player = None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Parse video page instead
|
# Parse video page instead
|
||||||
@ -294,6 +297,7 @@ class YouTube(VideoExtractor):
|
|||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
# VEVO
|
# VEVO
|
||||||
|
if not self.html5player: return
|
||||||
self.js = get_content(self.html5player)
|
self.js = get_content(self.html5player)
|
||||||
if 'adaptive_fmts' in ytplayer_config['args']:
|
if 'adaptive_fmts' in ytplayer_config['args']:
|
||||||
streams = [dict([(i.split('=')[0],
|
streams = [dict([(i.split('=')[0],
|
||||||
|
Loading…
Reference in New Issue
Block a user