]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/blinkx.py
144ce64ccacd35abbbf51392e192dff8a1ca1649
5 from .common
import InfoExtractor
11 class BlinkxIE(InfoExtractor
):
12 _VALID_URL
= r
'^(?:https?://(?:www\.)blinkx\.com/#?ce/|blinkx:)(?P<id>[^?]+)'
16 u
'url': u
'http://www.blinkx.com/ce/8aQUy7GVFYgFzpKhT0oqsilwOGFRVXk3R1ZGWWdGenBLaFQwb3FzaWx3OGFRVXk3R1ZGWWdGenB',
17 u
'file': u
'8aQUy7GV.mp4',
18 u
'md5': u
'2e9a07364af40163a908edbf10bb2492',
20 u
"title": u
"Police Car Rolls Away",
21 u
"uploader": u
"stupidvideos.com",
22 u
"upload_date": u
"20131215",
23 u
"description": u
"A police car gently rolls away from a fight. Maybe it felt weird being around a confrontation and just had to get out of there!",
28 "url": "http://cdn.blinkx.com/stream/b/41/StupidVideos/20131215/1873969261/1873969261_tn_0.jpg",
33 def _real_extract(self
, url
):
34 m
= re
.match(self
._VALID
_URL
, url
)
35 video_id
= m
.group('id')
36 display_id
= video_id
[:8]
38 api_url
= (u
'https://apib4.blinkx.com/api.php?action=play_video&' +
39 u
'video=%s' % video_id
)
40 data_json
= self
._download
_webpage
(api_url
, display_id
)
41 data
= json
.loads(data_json
)['api']['results'][0]
42 dt
= datetime
.datetime
.fromtimestamp(data
['pubdate_epoch'])
43 upload_date
= dt
.strftime('%Y%m%d')
48 for m
in data
['media']:
49 if m
['type'] == 'jpg':
53 'height': int(m
['h']),
55 elif m
['type'] == 'original':
57 elif m
['type'] == 'youtube':
59 self
.to_screen(u
'Youtube video detected: %s' % yt_id
)
60 return self
.url_result(yt_id
, 'Youtube', video_id
=yt_id
)
61 elif m
['type'] in ('flv', 'mp4'):
62 vcodec
= remove_start(m
['vcodec'], 'ff')
63 acodec
= remove_start(m
['acodec'], 'ff')
64 format_id
= (u
'%s-%sk-%s' %
66 (int(m
['vbr']) + int(m
['abr'])) // 1000,
69 'format_id': format_id
,
73 'abr': int(m
['abr']) // 1000,
74 'vbr': int(m
['vbr']) // 1000,
76 'height': int(m
['h']),
78 formats
.sort(key
=lambda f
: (f
['width'], f
['vbr'], f
['abr']))
83 'title': data
['title'],
85 'uploader': data
['channel_name'],
86 'upload_date': upload_date
,
87 'description': data
.get('description'),
88 'thumbnails': thumbnails
,