1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-03-13 06:20:29 +08:00

[dailymotion] fix embed page extractor

This commit is contained in:
Nicolas Silberman 2015-10-08 23:32:06 +02:00
parent 9d5fb3b58d
commit 2816cb33ff

View File

@ -43,11 +43,11 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
IE_NAME = 'dailymotion' IE_NAME = 'dailymotion'
_FORMATS = [ _FORMATS = [
('stream_h264_ld_url', 'ld'), ('240', 'ld'),
('stream_h264_url', 'standard'), ('380', 'standard'),
('stream_h264_hq_url', 'hq'), ('480', 'hq'),
('stream_h264_hd_url', 'hd'), ('720', 'hd'),
('stream_h264_hd1080_url', 'hd180'), ('1080', 'hd180'),
] ]
_TESTS = [ _TESTS = [
@ -197,7 +197,7 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
info = self._parse_json( info = self._parse_json(
self._search_regex( self._search_regex(
r'var info = ({.*?}),$', embed_page, r'getElementById\(\'player\'\), ({.*?})\);$', embed_page,
'video info', flags=re.MULTILINE), 'video info', flags=re.MULTILINE),
video_id) video_id)
@ -207,15 +207,15 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
formats = [] formats = []
for (key, format_id) in self._FORMATS: for (key, format_id) in self._FORMATS:
video_url = info.get(key) video_url = info.get('metadata').get('qualities').get(key)
if video_url is not None: if video_url is not None:
m_size = re.search(r'H264-(\d+)x(\d+)', video_url) m_size = re.search(r'H264-(\d+)x(\d+)', video_url[0].get("url"))
if m_size is not None: if m_size is not None:
width, height = map(int_or_none, (m_size.group(1), m_size.group(2))) width, height = map(int_or_none, (m_size.group(1), m_size.group(2)))
else: else:
width, height = None, None width, height = None, None
formats.append({ formats.append({
'url': video_url, 'url': video_url[0].get("url"),
'ext': 'mp4', 'ext': 'mp4',
'format_id': format_id, 'format_id': format_id,
'width': width, 'width': width,
@ -225,25 +225,23 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
# subtitles # subtitles
video_subtitles = self.extract_subtitles(video_id, webpage) video_subtitles = self.extract_subtitles(video_id, webpage)
title = self._og_search_title(webpage, default=None) title = self._og_search_title(webpage, default=None)
if title is None: if title is None:
title = self._html_search_regex( title = self._html_search_regex(
r'(?s)<span\s+id="video_title"[^>]*>(.*?)</span>', webpage, r'(?s)<span\s+id="video_title"[^>]*>(.*?)</span>', webpage,
'title') 'title')
return { return {
'id': video_id, 'id': video_id,
'formats': formats, 'formats': formats,
'uploader': info['owner.screenname'], 'uploader': info.get('metadata').get('owner').get('screenname'),
'timestamp': timestamp, 'timestamp': timestamp,
'title': title, 'title': title,
'description': description, 'description': description,
'subtitles': video_subtitles, 'subtitles': video_subtitles,
'thumbnail': info['thumbnail_url'],
'age_limit': age_limit, 'age_limit': age_limit,
'view_count': view_count, 'view_count': view_count,
'duration': info['duration'] 'duration': info.get('metadata').get('duration')
} }
def _get_subtitles(self, video_id, webpage): def _get_subtitles(self, video_id, webpage):