1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-25 17:55:35 +08:00

[blinkx] Modernize

This commit is contained in:
Sergey M․ 2014-06-11 18:38:13 +07:00
parent fdb9aebead
commit 8f93030c85

View File

@ -4,9 +4,7 @@ import json
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import remove_start
remove_start,
)
class BlinkxIE(InfoExtractor): class BlinkxIE(InfoExtractor):
@ -15,9 +13,10 @@ class BlinkxIE(InfoExtractor):
_TEST = { _TEST = {
'url': 'http://www.blinkx.com/ce/8aQUy7GVFYgFzpKhT0oqsilwOGFRVXk3R1ZGWWdGenBLaFQwb3FzaWx3OGFRVXk3R1ZGWWdGenB', 'url': 'http://www.blinkx.com/ce/8aQUy7GVFYgFzpKhT0oqsilwOGFRVXk3R1ZGWWdGenBLaFQwb3FzaWx3OGFRVXk3R1ZGWWdGenB',
'file': '8aQUy7GV.mp4',
'md5': '2e9a07364af40163a908edbf10bb2492', 'md5': '2e9a07364af40163a908edbf10bb2492',
'info_dict': { 'info_dict': {
'id': '8aQUy7GV',
'ext': 'mp4',
'title': 'Police Car Rolls Away', 'title': 'Police Car Rolls Away',
'uploader': 'stupidvideos.com', 'uploader': 'stupidvideos.com',
'upload_date': '20131215', 'upload_date': '20131215',
@ -27,6 +26,7 @@ class BlinkxIE(InfoExtractor):
'thumbnails': [{ 'thumbnails': [{
'width': 100, 'width': 100,
'height': 76, 'height': 76,
'resolution': '100x76',
'url': 'http://cdn.blinkx.com/stream/b/41/StupidVideos/20131215/1873969261/1873969261_tn_0.jpg', 'url': 'http://cdn.blinkx.com/stream/b/41/StupidVideos/20131215/1873969261/1873969261_tn_0.jpg',
}], }],
}, },
@ -37,7 +37,7 @@ class BlinkxIE(InfoExtractor):
video_id = m.group('id') video_id = m.group('id')
display_id = video_id[:8] display_id = video_id[:8]
api_url = (u'https://apib4.blinkx.com/api.php?action=play_video&' + api_url = ('https://apib4.blinkx.com/api.php?action=play_video&' +
'video=%s' % video_id) 'video=%s' % video_id)
data_json = self._download_webpage(api_url, display_id) data_json = self._download_webpage(api_url, display_id)
data = json.loads(data_json)['api']['results'][0] data = json.loads(data_json)['api']['results'][0]
@ -55,13 +55,13 @@ class BlinkxIE(InfoExtractor):
duration = m['d'] duration = m['d']
elif m['type'] == 'youtube': elif m['type'] == 'youtube':
yt_id = m['link'] yt_id = m['link']
self.to_screen(u'Youtube video detected: %s' % yt_id) self.to_screen('Youtube video detected: %s' % yt_id)
return self.url_result(yt_id, 'Youtube', video_id=yt_id) return self.url_result(yt_id, 'Youtube', video_id=yt_id)
elif m['type'] in ('flv', 'mp4'): elif m['type'] in ('flv', 'mp4'):
vcodec = remove_start(m['vcodec'], 'ff') vcodec = remove_start(m['vcodec'], 'ff')
acodec = remove_start(m['acodec'], 'ff') acodec = remove_start(m['acodec'], 'ff')
tbr = (int(m['vbr']) + int(m['abr'])) // 1000 tbr = (int(m['vbr']) + int(m['abr'])) // 1000
format_id = u'%s-%sk-%s' % (vcodec, tbr, m['w']) format_id = '%s-%sk-%s' % (vcodec, tbr, m['w'])
formats.append({ formats.append({
'format_id': format_id, 'format_id': format_id,
'url': m['link'], 'url': m['link'],