]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/dailymail.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  11 class DailyMailIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'https?://(?:www\.)?dailymail\.co\.uk/video/[^/]+/video-(?P<id>[0-9]+)' 
  14         'url': 'http://www.dailymail.co.uk/video/sciencetech/video-1288527/Turn-video-impressionist-masterpiece.html', 
  15         'md5': '2f639d446394f53f3a33658b518b6615', 
  19             'title': 'Turn any video into an impressionist masterpiece', 
  20             'description': 'md5:88ddbcb504367987b2708bb38677c9d2', 
  24     def _real_extract(self
, url
): 
  25         video_id 
= self
._match
_id
(url
) 
  26         webpage 
= self
._download
_webpage
(url
, video_id
) 
  27         video_data 
= self
._parse
_json
(self
._search
_regex
( 
  28             r
"data-opts='({.+?})'", webpage
, 'video data'), video_id
) 
  29         title 
= video_data
['title'] 
  30         video_sources 
= self
._download
_json
(video_data
.get( 
  31             'sources', {}).get('url') or 'http://www.dailymail.co.uk/api/player/%s/video-sources.json' % video_id
, video_id
) 
  34         for rendition 
in video_sources
['renditions']: 
  35             rendition_url 
= rendition
.get('url') 
  38             tbr 
= int_or_none(rendition
.get('encodingRate'), 1000) 
  39             container 
= rendition
.get('videoContainer') 
  40             is_hls 
= container 
== 'M2TS' 
  41             protocol 
= 'm3u8_native' if is_hls 
else determine_protocol({'url': rendition_url
}) 
  43                 'format_id': ('hls' if is_hls 
else protocol
) + ('-%d' % tbr 
if tbr 
else ''), 
  45                 'width': int_or_none(rendition
.get('frameWidth')), 
  46                 'height': int_or_none(rendition
.get('frameHeight')), 
  48                 'vcodec': rendition
.get('videoCodec'), 
  49                 'container': container
, 
  51                 'ext': 'mp4' if is_hls 
else None, 
  53         self
._sort
_formats
(formats
) 
  58             'description': video_data
.get('descr'), 
  59             'thumbnail': video_data
.get('poster') or video_data
.get('thumbnail'),