]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/dailymail.py
af39780353ac1e044ffb07464dfa64032ba18f0e
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
16 class DailyMailIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?dailymail\.co\.uk/(?:video/[^/]+/video-|embed/video/)(?P<id>[0-9]+)'
19 'url': 'http://www.dailymail.co.uk/video/tvshowbiz/video-1295863/The-Mountain-appears-sparkling-water-ad-Heavy-Bubbles.html',
20 'md5': 'f6129624562251f628296c3a9ffde124',
24 'title': 'The Mountain appears in sparkling water ad for \'Heavy Bubbles\'',
25 'description': 'md5:a93d74b6da172dd5dc4d973e0b766a84',
28 'url': 'http://www.dailymail.co.uk/embed/video/1295863.html',
29 'only_matching': True,
33 def _extract_urls(webpage
):
35 r
'<iframe\b[^>]+\bsrc=["\'](?P
<url
>(?
:https?
:)?
//(?
:www\
.)?dailymail\
.co\
.uk
/embed
/video
/\d
+\
.html
)',
38 def _real_extract(self, url):
39 video_id = self._match_id(url)
40 webpage = self._download_webpage(url, video_id)
41 video_data = self._parse_json(self._search_regex(
42 r"data-opts='({.+?
})'", webpage, 'video data
'), video_id)
43 title = unescapeHTML(video_data['title
'])
45 sources_url = (try_get(
47 (lambda x: x['plugins
']['sources
']['url
'],
48 lambda x: x['sources
']['url
']), compat_str) or
49 'http
://www
.dailymail
.co
.uk
/api
/player
/%s/video
-sources
.json
' % video_id)
51 video_sources = self._download_json(sources_url, video_id)
54 for rendition in video_sources['renditions
']:
55 rendition_url = rendition.get('url
')
58 tbr = int_or_none(rendition.get('encodingRate
'), 1000)
59 container = rendition.get('videoContainer
')
60 is_hls = container == 'M2TS
'
61 protocol = 'm3u8_native
' if is_hls else determine_protocol({'url
': rendition_url})
63 'format_id
': ('hls
' if is_hls else protocol) + ('-%d' % tbr if tbr else ''),
65 'width
': int_or_none(rendition.get('frameWidth
')),
66 'height
': int_or_none(rendition.get('frameHeight
')),
68 'vcodec
': rendition.get('videoCodec
'),
69 'container
': container,
71 'ext
': 'mp4
' if is_hls else None,
73 self._sort_formats(formats)
78 'description
': unescapeHTML(video_data.get('descr
')),
79 'thumbnail
': video_data.get('poster
') or video_data.get('thumbnail
'),