]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/dailymail.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
12 class DailyMailIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:www\.)?dailymail\.co\.uk/video/[^/]+/video-(?P<id>[0-9]+)'
15 'url': 'http://www.dailymail.co.uk/video/tvshowbiz/video-1295863/The-Mountain-appears-sparkling-water-ad-Heavy-Bubbles.html',
16 'md5': 'f6129624562251f628296c3a9ffde124',
20 'title': 'The Mountain appears in sparkling water ad for \'Heavy Bubbles\'',
21 'description': 'md5:a93d74b6da172dd5dc4d973e0b766a84',
25 def _real_extract(self
, url
):
26 video_id
= self
._match
_id
(url
)
27 webpage
= self
._download
_webpage
(url
, video_id
)
28 video_data
= self
._parse
_json
(self
._search
_regex
(
29 r
"data-opts='({.+?})'", webpage
, 'video data'), video_id
)
30 title
= unescapeHTML(video_data
['title'])
31 video_sources
= self
._download
_json
(video_data
.get(
32 'sources', {}).get('url') or 'http://www.dailymail.co.uk/api/player/%s/video-sources.json' % video_id
, video_id
)
35 for rendition
in video_sources
['renditions']:
36 rendition_url
= rendition
.get('url')
39 tbr
= int_or_none(rendition
.get('encodingRate'), 1000)
40 container
= rendition
.get('videoContainer')
41 is_hls
= container
== 'M2TS'
42 protocol
= 'm3u8_native' if is_hls
else determine_protocol({'url': rendition_url
})
44 'format_id': ('hls' if is_hls
else protocol
) + ('-%d' % tbr
if tbr
else ''),
46 'width': int_or_none(rendition
.get('frameWidth')),
47 'height': int_or_none(rendition
.get('frameHeight')),
49 'vcodec': rendition
.get('videoCodec'),
50 'container': container
,
52 'ext': 'mp4' if is_hls
else None,
54 self
._sort
_formats
(formats
)
59 'description': unescapeHTML(video_data
.get('descr')),
60 'thumbnail': video_data
.get('poster') or video_data
.get('thumbnail'),