X-Git-Url: https://git.rapsys.eu/youtubedl/blobdiff_plain/63a6927374492ef47c8fd6de67d0760ace4dd0ed..c9774cf13273185f8f8075590dce493a18ead418:/youtube_dl/extractor/blinkx.py?ds=inline diff --git a/youtube_dl/extractor/blinkx.py b/youtube_dl/extractor/blinkx.py index 144ce64..38ccd95 100644 --- a/youtube_dl/extractor/blinkx.py +++ b/youtube_dl/extractor/blinkx.py @@ -1,4 +1,5 @@ -import datetime +from __future__ import unicode_literals + import json import re @@ -10,38 +11,36 @@ from ..utils import ( class BlinkxIE(InfoExtractor): _VALID_URL = r'^(?:https?://(?:www\.)blinkx\.com/#?ce/|blinkx:)(?P[^?]+)' - _IE_NAME = u'blinkx' + IE_NAME = 'blinkx' _TEST = { - u'url': u'http://www.blinkx.com/ce/8aQUy7GVFYgFzpKhT0oqsilwOGFRVXk3R1ZGWWdGenBLaFQwb3FzaWx3OGFRVXk3R1ZGWWdGenB', - u'file': u'8aQUy7GV.mp4', - u'md5': u'2e9a07364af40163a908edbf10bb2492', - u'info_dict': { - u"title": u"Police Car Rolls Away", - u"uploader": u"stupidvideos.com", - u"upload_date": u"20131215", - 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!", - u"duration": 14.886, - u"thumbnails": [{ - "width": 100, - "height": 76, - "url": "http://cdn.blinkx.com/stream/b/41/StupidVideos/20131215/1873969261/1873969261_tn_0.jpg", + 'url': 'http://www.blinkx.com/ce/8aQUy7GVFYgFzpKhT0oqsilwOGFRVXk3R1ZGWWdGenBLaFQwb3FzaWx3OGFRVXk3R1ZGWWdGenB', + 'file': '8aQUy7GV.mp4', + 'md5': '2e9a07364af40163a908edbf10bb2492', + 'info_dict': { + 'title': 'Police Car Rolls Away', + 'uploader': 'stupidvideos.com', + 'upload_date': '20131215', + 'timestamp': 1387068000, + 'description': '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!', + 'duration': 14.886, + 'thumbnails': [{ + 'width': 100, + 'height': 76, + 'url': 'http://cdn.blinkx.com/stream/b/41/StupidVideos/20131215/1873969261/1873969261_tn_0.jpg', }], }, } - def _real_extract(self, url): - m = re.match(self._VALID_URL, url) + def _real_extract(self, rl): + m = re.match(self._VALID_URL, rl) video_id = m.group('id') display_id = video_id[:8] api_url = (u'https://apib4.blinkx.com/api.php?action=play_video&' + - u'video=%s' % video_id) + 'video=%s' % video_id) data_json = self._download_webpage(api_url, display_id) data = json.loads(data_json)['api']['results'][0] - dt = datetime.datetime.fromtimestamp(data['pubdate_epoch']) - upload_date = dt.strftime('%Y%m%d') - duration = None thumbnails = [] formats = [] @@ -61,10 +60,8 @@ class BlinkxIE(InfoExtractor): elif m['type'] in ('flv', 'mp4'): vcodec = remove_start(m['vcodec'], 'ff') acodec = remove_start(m['acodec'], 'ff') - format_id = (u'%s-%sk-%s' % - (vcodec, - (int(m['vbr']) + int(m['abr'])) // 1000, - m['w'])) + tbr = (int(m['vbr']) + int(m['abr'])) // 1000 + format_id = u'%s-%sk-%s' % (vcodec, tbr, m['w']) formats.append({ 'format_id': format_id, 'url': m['link'], @@ -72,10 +69,12 @@ class BlinkxIE(InfoExtractor): 'acodec': acodec, 'abr': int(m['abr']) // 1000, 'vbr': int(m['vbr']) // 1000, + 'tbr': tbr, 'width': int(m['w']), 'height': int(m['h']), }) - formats.sort(key=lambda f: (f['width'], f['vbr'], f['abr'])) + + self._sort_formats(formats) return { 'id': display_id, @@ -83,7 +82,7 @@ class BlinkxIE(InfoExtractor): 'title': data['title'], 'formats': formats, 'uploader': data['channel_name'], - 'upload_date': upload_date, + 'timestamp': data['pubdate_epoch'], 'description': data.get('description'), 'thumbnails': thumbnails, 'duration': duration,