mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45:02 +03:00
[youtube] we should extract ytInitialPlayerResponse more reliably
This commit is contained in:
parent
6ddc3fce89
commit
c0151a9775
@ -237,7 +237,10 @@ class YouTube(VideoExtractor):
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
# ytplayer_config = {args:{raw_player_response:ytInitialPlayerResponse}}
|
# ytplayer_config = {args:{raw_player_response:ytInitialPlayerResponse}}
|
||||||
|
try: # FIXME: we should extract ytInitialPlayerResponse more reliably
|
||||||
ytInitialPlayerResponse = json.loads(re.search('ytInitialPlayerResponse\s*=\s*([^\n]+?});</script>', video_page).group(1))
|
ytInitialPlayerResponse = json.loads(re.search('ytInitialPlayerResponse\s*=\s*([^\n]+?});</script>', video_page).group(1))
|
||||||
|
except:
|
||||||
|
ytInitialPlayerResponse = json.loads(re.search('ytInitialPlayerResponse\s*=\s*([^\n]+?});', video_page).group(1))
|
||||||
|
|
||||||
stream_list = ytInitialPlayerResponse['streamingData']['formats']
|
stream_list = ytInitialPlayerResponse['streamingData']['formats']
|
||||||
#stream_list = ytInitialPlayerResponse['streamingData']['adaptiveFormats']
|
#stream_list = ytInitialPlayerResponse['streamingData']['adaptiveFormats']
|
||||||
@ -262,7 +265,10 @@ class YouTube(VideoExtractor):
|
|||||||
# Parse video page instead
|
# Parse video page instead
|
||||||
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: # FIXME: we should extract ytInitialPlayerResponse more reliably
|
||||||
ytInitialPlayerResponse = json.loads(re.search('ytInitialPlayerResponse\s*=\s*([^\n]+?});</script>', video_page).group(1))
|
ytInitialPlayerResponse = json.loads(re.search('ytInitialPlayerResponse\s*=\s*([^\n]+?});</script>', video_page).group(1))
|
||||||
|
except:
|
||||||
|
ytInitialPlayerResponse = json.loads(re.search('ytInitialPlayerResponse\s*=\s*([^\n]+?});', video_page).group(1))
|
||||||
|
|
||||||
self.title = ytInitialPlayerResponse["videoDetails"]["title"]
|
self.title = ytInitialPlayerResponse["videoDetails"]["title"]
|
||||||
if re.search('([^"]*/base\.js)"', video_page):
|
if re.search('([^"]*/base\.js)"', video_page):
|
||||||
|
Loading…
Reference in New Issue
Block a user