[blinkx] Fix extraction

This commit is contained in:
Sergey M․ 2015-02-20 01:19:38 +06:00
parent a21420389e
commit dd0a58f5f0
1 changed files with 23 additions and 26 deletions

View File

@ -1,40 +1,35 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import json import json
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import remove_start from ..utils import (
remove_start,
int_or_none,
)
class BlinkxIE(InfoExtractor): class BlinkxIE(InfoExtractor):
_VALID_URL = r'^(?:https?://(?:www\.)blinkx\.com/#?ce/|blinkx:)(?P<id>[^?]+)' _VALID_URL = r'(?:https?://(?:www\.)blinkx\.com/#?ce/|blinkx:)(?P<id>[^?]+)'
IE_NAME = 'blinkx' IE_NAME = 'blinkx'
_TEST = { _TEST = {
'url': 'http://www.blinkx.com/ce/8aQUy7GVFYgFzpKhT0oqsilwOGFRVXk3R1ZGWWdGenBLaFQwb3FzaWx3OGFRVXk3R1ZGWWdGenB', 'url': 'http://www.blinkx.com/ce/Da0Gw3xc5ucpNduzLuDDlv4WC9PuI4fDi1-t6Y3LyfdY2SZS5Urbvn-UPJvrvbo8LTKTc67Wu2rPKSQDJyZeeORCR8bYkhs8lI7eqddznH2ofh5WEEdjYXnoRtj7ByQwt7atMErmXIeYKPsSDuMAAqJDlQZ-3Ff4HJVeH_s3Gh8oQ',
'md5': '2e9a07364af40163a908edbf10bb2492', 'md5': '337cf7a344663ec79bf93a526a2e06c7',
'info_dict': { 'info_dict': {
'id': '8aQUy7GV', 'id': 'Da0Gw3xc',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Police Car Rolls Away', 'title': 'No Daily Show for John Oliver; HBO Show Renewed - IGN News',
'uploader': 'stupidvideos.com', 'uploader': 'IGN News',
'upload_date': '20131215', 'upload_date': '20150217',
'timestamp': 1387068000, 'timestamp': 1424215740,
'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!', 'description': 'HBO has renewed Last Week Tonight With John Oliver for two more seasons.',
'duration': 14.886, 'duration': 47.743333,
'thumbnails': [{
'width': 100,
'height': 76,
'resolution': '100x76',
'url': 'http://cdn.blinkx.com/stream/b/41/StupidVideos/20131215/1873969261/1873969261_tn_0.jpg',
}],
}, },
} }
def _real_extract(self, rl): def _real_extract(self, url):
m = re.match(self._VALID_URL, rl) video_id = self._match_id(url)
video_id = m.group('id')
display_id = video_id[:8] display_id = video_id[:8]
api_url = ('https://apib4.blinkx.com/api.php?action=play_video&' + api_url = ('https://apib4.blinkx.com/api.php?action=play_video&' +
@ -60,18 +55,20 @@ class BlinkxIE(InfoExtractor):
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 vbr = int_or_none(m.get('vbr') or m.get('vbitrate'), 1000)
abr = int_or_none(m.get('abr') or m.get('abitrate'), 1000)
tbr = vbr + abr if vbr and abr else None
format_id = '%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'],
'vcodec': vcodec, 'vcodec': vcodec,
'acodec': acodec, 'acodec': acodec,
'abr': int(m['abr']) // 1000, 'abr': abr,
'vbr': int(m['vbr']) // 1000, 'vbr': vbr,
'tbr': tbr, 'tbr': tbr,
'width': int(m['w']), 'width': int_or_none(m.get('w')),
'height': int(m['h']), 'height': int_or_none(m.get('h')),
}) })
self._sort_formats(formats) self._sort_formats(formats)