]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/blinkx.py
3b8eabe8f4e42283eaa8a2288413f971fdcd5b35
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
12 class BlinkxIE(InfoExtractor
):
13 _VALID_URL
= r
'(?:https?://(?:www\.)blinkx\.com/#?ce/|blinkx:)(?P<id>[^?]+)'
17 'url': 'http://www.blinkx.com/ce/Da0Gw3xc5ucpNduzLuDDlv4WC9PuI4fDi1-t6Y3LyfdY2SZS5Urbvn-UPJvrvbo8LTKTc67Wu2rPKSQDJyZeeORCR8bYkhs8lI7eqddznH2ofh5WEEdjYXnoRtj7ByQwt7atMErmXIeYKPsSDuMAAqJDlQZ-3Ff4HJVeH_s3Gh8oQ',
18 'md5': '337cf7a344663ec79bf93a526a2e06c7',
22 'title': 'No Daily Show for John Oliver; HBO Show Renewed - IGN News',
23 'uploader': 'IGN News',
24 'upload_date': '20150217',
25 'timestamp': 1424215740,
26 'description': 'HBO has renewed Last Week Tonight With John Oliver for two more seasons.',
27 'duration': 47.743333,
31 def _real_extract(self
, url
):
32 video_id
= self
._match
_id
(url
)
33 display_id
= video_id
[:8]
35 api_url
= ('https://apib4.blinkx.com/api.php?action=play_video&' +
36 'video=%s' % video_id
)
37 data_json
= self
._download
_webpage
(api_url
, display_id
)
38 data
= json
.loads(data_json
)['api']['results'][0]
42 for m
in data
['media']:
43 if m
['type'] == 'jpg':
47 'height': int(m
['h']),
49 elif m
['type'] == 'original':
50 duration
= float(m
['d'])
51 elif m
['type'] == 'youtube':
53 self
.to_screen('Youtube video detected: %s' % yt_id
)
54 return self
.url_result(yt_id
, 'Youtube', video_id
=yt_id
)
55 elif m
['type'] in ('flv', 'mp4'):
56 vcodec
= remove_start(m
['vcodec'], 'ff')
57 acodec
= remove_start(m
['acodec'], 'ff')
58 vbr
= int_or_none(m
.get('vbr') or m
.get('vbitrate'), 1000)
59 abr
= int_or_none(m
.get('abr') or m
.get('abitrate'), 1000)
60 tbr
= vbr
+ abr
if vbr
and abr
else None
61 format_id
= '%s-%sk-%s' % (vcodec
, tbr
, m
['w'])
63 'format_id': format_id
,
70 'width': int_or_none(m
.get('w')),
71 'height': int_or_none(m
.get('h')),
74 self
._sort
_formats
(formats
)
79 'title': data
['title'],
81 'uploader': data
['channel_name'],
82 'timestamp': data
['pubdate_epoch'],
83 'description': data
.get('description'),
84 'thumbnails': thumbnails
,