[vgtv] extract all formats and improve extraction

This commit is contained in:
remitamine 2015-12-06 07:43:46 +01:00
parent 804afc5871
commit 9f6b517671

View File

@ -13,7 +13,7 @@ from ..utils import (
class VGTVIE(InfoExtractor): class VGTVIE(InfoExtractor):
IE_DESC = 'VGTV, BTTV, FTV, Aftenposten and Aftonbladet' IE_DESC = 'VGTV, BTTV, FTV, Aftenposten and Aftonbladet'
_VALID_URL = r'''(?x) _VALID_URL = r'''(?x)
http://(?:www\.)? https?://(?:www\.)?
(?P<host> (?P<host>
vgtv.no| vgtv.no|
(?:bt|aftenbladet).no/tv| (?:bt|aftenbladet).no/tv|
@ -25,7 +25,7 @@ class VGTVIE(InfoExtractor):
\#!/(?:video|live)/| \#!/(?:video|live)/|
embed?.*id= embed?.*id=
) )
(?P<id>[0-9]+) (?P<id>\d+)
''' '''
_TESTS = [ _TESTS = [
{ {
@ -82,7 +82,8 @@ class VGTVIE(InfoExtractor):
# m3u8 download # m3u8 download
'skip_download': True, 'skip_download': True,
}, },
},{ },
{
'url': 'http://www.aftenposten.no/webtv/#!/video/21039/trailer-sweatshop-i-can-t-take-any-more', 'url': 'http://www.aftenposten.no/webtv/#!/video/21039/trailer-sweatshop-i-can-t-take-any-more',
'md5': '7fbc265a3ca4933a423c7a66aa879a67', 'md5': '7fbc265a3ca4933a423c7a66aa879a67',
'info_dict': { 'info_dict': {
@ -145,35 +146,37 @@ class VGTVIE(InfoExtractor):
hls_url = streams.get('hls') hls_url = streams.get('hls')
if hls_url: if hls_url:
formats.extend(self._extract_m3u8_formats( m3u8_formats = self._extract_m3u8_formats(hls_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
hls_url, video_id, 'mp4', m3u8_id='hls')) if m3u8_formats:
formats.extend(m3u8_formats)
hds_url = streams.get('hds') hds_url = streams.get('hds')
# wasLive hds are always 404 # wasLive hds are always 404
if hds_url and stream_type != 'wasLive': if hds_url and stream_type != 'wasLive':
formats.extend(self._extract_f4m_formats( f4m_formats = self._extract_f4m_formats(hds_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18', video_id, f4m_id='hds', fatal=False)
hds_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18', if f4m_formats:
video_id, f4m_id='hds')) formats.extend(f4m_formats)
mp4_urls = streams.get('pseudostreaming') or []
mp4_url = streams.get('mp4') mp4_url = streams.get('mp4')
if mp4_url: if mp4_url:
_url = hls_url or hds_url mp4_urls.append(mp4_url)
MP4_URL_TEMPLATE = '%s/%%s.%s' % (mp4_url.rpartition('/')[0], mp4_url.rpartition('.')[-1]) for mp4_url in mp4_urls:
for mp4_format in _url.split(','): format_info = {
m = re.search('(?P<width>\d+)_(?P<height>\d+)_(?P<vbr>\d+)', mp4_format) 'url': mp4_url,
if not m: 'preference': 1,
continue }
width = int(m.group('width')) mobj = re.search('(\d+)_(\d+)_(\d+)', mp4_url)
height = int(m.group('height')) if mobj:
vbr = int(m.group('vbr')) vbr = int(mobj.group(3))
formats.append({ format_info.update({
'url': MP4_URL_TEMPLATE % mp4_format, 'width': int(mobj.group(1)),
'format_id': 'mp4-%s' % vbr, 'height': int(mobj.group(2)),
'width': width,
'height': height,
'vbr': vbr, 'vbr': vbr,
'preference': 1, 'format_id': 'mp4-%s' % vbr,
}) })
formats.append(format_info)
self._sort_formats(formats) self._sort_formats(formats)
return { return {
@ -234,4 +237,4 @@ class BTVestlendingenIE(InfoExtractor):
} }
def _real_extract(self, url): def _real_extract(self, url):
return self.url_result('xstream:btno:%s' % self._match_id(url), 'Xstream') return self.url_result('http://bt.no/tv/embed?id=%s' % self._match_id(url), 'VGTV')