Simplify formats accumulation for f4m/m3u8/smil formats

Now all _extract_*_formats routines return a list
This commit is contained in:
Sergey M․ 2015-12-29 00:58:24 +06:00
parent 39d60b715a
commit 7e5edcfd33
32 changed files with 99 additions and 215 deletions

View file

@ -53,16 +53,12 @@ class AMPIE(InfoExtractor):
media = media_data['@attributes'] media = media_data['@attributes']
media_type = media['type'] media_type = media['type']
if media_type == 'video/f4m': if media_type == 'video/f4m':
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
media['url'] + '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124', media['url'] + '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124',
video_id, f4m_id='hds', fatal=False) video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
elif media_type == 'application/x-mpegURL': elif media_type == 'application/x-mpegURL':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
media['url'], video_id, 'mp4', m3u8_id='hls', fatal=False) media['url'], video_id, 'mp4', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
formats.append({ formats.append({
'format_id': media_data['media-category']['@attributes']['label'], 'format_id': media_data['media-category']['@attributes']['label'],

View file

@ -113,16 +113,12 @@ class ARDMediathekIE(InfoExtractor):
if quality != 'auto' and ext in ('f4m', 'm3u8'): if quality != 'auto' and ext in ('f4m', 'm3u8'):
continue continue
if ext == 'f4m': if ext == 'f4m':
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
stream_url + '?hdcore=3.1.1&plugin=aasp-3.1.1.69.124', stream_url + '?hdcore=3.1.1&plugin=aasp-3.1.1.69.124',
video_id, preference=-1, f4m_id='hds', fatal=False) video_id, preference=-1, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
elif ext == 'm3u8': elif ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
stream_url, video_id, 'mp4', preference=1, m3u8_id='hls', fatal=False) stream_url, video_id, 'mp4', preference=1, m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
if server and server.startswith('rtmp'): if server and server.startswith('rtmp'):
f = { f = {

View file

@ -134,10 +134,8 @@ class AtresPlayerIE(InfoExtractor):
m3u8_url = player.get('urlVideoHls') m3u8_url = player.get('urlVideoHls')
if m3u8_url: if m3u8_url:
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, episode_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) m3u8_url, episode_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
timestamp = int_or_none(self._download_webpage( timestamp = int_or_none(self._download_webpage(
self._TIME_API_URL, self._TIME_API_URL,
@ -170,9 +168,7 @@ class AtresPlayerIE(InfoExtractor):
continue continue
else: else:
f4m_url = video_url[:-9] + '/manifest.f4m' f4m_url = video_url[:-9] + '/manifest.f4m'
f4m_formats = self._extract_f4m_formats(f4m_url, video_id, f4m_id='hds', fatal=False) formats.extend(self._extract_f4m_formats(f4m_url, video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
self._sort_formats(formats) self._sort_formats(formats)
path_data = player.get('pathData') path_data = player.get('pathData')

View file

@ -45,15 +45,11 @@ class AudiMediaIE(InfoExtractor):
stream_url_hls = json_data.get('stream_url_hls') stream_url_hls = json_data.get('stream_url_hls')
if stream_url_hls: if stream_url_hls:
m3u8_formats = self._extract_m3u8_formats(stream_url_hls, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) formats.extend(self._extract_m3u8_formats(stream_url_hls, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
stream_url_hds = json_data.get('stream_url_hds') stream_url_hds = json_data.get('stream_url_hds')
if stream_url_hds: if stream_url_hds:
f4m_formats = self._extract_f4m_formats(json_data.get('stream_url_hds') + '?hdcore=3.4.0', video_id, -1, f4m_id='hds', fatal=False) formats.extend(self._extract_f4m_formats(json_data.get('stream_url_hds') + '?hdcore=3.4.0', video_id, -1, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
for video_version in json_data.get('video_versions'): for video_version in json_data.get('video_versions'):
video_version_url = video_version.get('download_url') or video_version.get('stream_url') video_version_url = video_version.get('download_url') or video_version.get('stream_url')

View file

@ -223,11 +223,9 @@ class BBCCoUkIE(InfoExtractor):
elif transfer_format == 'dash': elif transfer_format == 'dash':
pass pass
elif transfer_format == 'hls': elif transfer_format == 'hls':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
href, programme_id, ext='mp4', entry_protocol='m3u8_native', href, programme_id, ext='mp4', entry_protocol='m3u8_native',
m3u8_id=supplier, fatal=False) m3u8_id=supplier, fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
# Direct link # Direct link
else: else:
formats.append({ formats.append({

View file

@ -41,15 +41,11 @@ class BloombergIE(InfoExtractor):
if not stream_url: if not stream_url:
continue continue
if stream['muxing_format'] == 'TS': if stream['muxing_format'] == 'TS':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
stream_url, video_id, 'mp4', m3u8_id='hls', fatal=False) stream_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
stream_url, video_id, f4m_id='hds', fatal=False) stream_url, video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
self._sort_formats(formats) self._sort_formats(formats)
return { return {

View file

@ -121,15 +121,11 @@ class BRIE(InfoExtractor):
format_url = xpath_text(asset, ['downloadUrl', 'url']) format_url = xpath_text(asset, ['downloadUrl', 'url'])
asset_type = asset.get('type') asset_type = asset.get('type')
if asset_type == 'HDS': if asset_type == 'HDS':
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
format_url + '?hdcore=3.2.0', media_id, f4m_id='hds', fatal=False) format_url + '?hdcore=3.2.0', media_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
elif asset_type == 'HLS': elif asset_type == 'HLS':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
format_url, media_id, 'mp4', 'm3u8_native', m3u8_id='hds', fatal=False) format_url, media_id, 'mp4', 'm3u8_native', m3u8_id='hds', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
format_info = { format_info = {
'ext': xpath_text(asset, 'mediaType'), 'ext': xpath_text(asset, 'mediaType'),

View file

@ -469,11 +469,9 @@ class BrightcoveNewIE(InfoExtractor):
if source_type == 'application/x-mpegURL': if source_type == 'application/x-mpegURL':
if not src: if not src:
continue continue
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
src, video_id, 'mp4', entry_protocol='m3u8_native', src, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls', fatal=False) m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
streaming_src = source.get('streaming_src') streaming_src = source.get('streaming_src')
stream_name, app_name = source.get('stream_name'), source.get('app_name') stream_name, app_name = source.get('stream_name'), source.get('app_name')

View file

@ -910,10 +910,8 @@ class InfoExtractor(object):
# may differ leading to inability to resolve the format by requested # may differ leading to inability to resolve the format by requested
# bitrate in f4m downloader # bitrate in f4m downloader
if determine_ext(manifest_url) == 'f4m': if determine_ext(manifest_url) == 'f4m':
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
manifest_url, video_id, preference, f4m_id, fatal=fatal) manifest_url, video_id, preference, f4m_id, fatal=fatal))
if f4m_formats:
formats.extend(f4m_formats)
continue continue
tbr = int_or_none(media_el.attrib.get('bitrate')) tbr = int_or_none(media_el.attrib.get('bitrate'))
formats.append({ formats.append({
@ -1147,10 +1145,8 @@ class InfoExtractor(object):
src_url = src if src.startswith('http') else compat_urlparse.urljoin(base, src) src_url = src if src.startswith('http') else compat_urlparse.urljoin(base, src)
if proto == 'm3u8' or src_ext == 'm3u8': if proto == 'm3u8' or src_ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
src_url, video_id, ext or 'mp4', m3u8_id='hls', fatal=False) src_url, video_id, ext or 'mp4', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
continue continue
if src_ext == 'f4m': if src_ext == 'f4m':
@ -1162,9 +1158,7 @@ class InfoExtractor(object):
} }
f4m_url += '&' if '?' in f4m_url else '?' f4m_url += '&' if '?' in f4m_url else '?'
f4m_url += compat_urllib_parse.urlencode(f4m_params) f4m_url += compat_urllib_parse.urlencode(f4m_params)
f4m_formats = self._extract_f4m_formats(f4m_url, video_id, f4m_id='hds', fatal=False) formats.extend(self._extract_f4m_formats(f4m_url, video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
continue continue
if src_url.startswith('http') and self._is_valid_url(src, video_id): if src_url.startswith('http') and self._is_valid_url(src, video_id):

View file

@ -148,15 +148,11 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
continue continue
ext = determine_ext(media_url) ext = determine_ext(media_url)
if type_ == 'application/x-mpegURL' or ext == 'm3u8': if type_ == 'application/x-mpegURL' or ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
media_url, video_id, 'mp4', m3u8_id='hls', fatal=False) media_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif type_ == 'application/f4m' or ext == 'f4m': elif type_ == 'application/f4m' or ext == 'f4m':
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
media_url, video_id, preference=-1, f4m_id='hds', fatal=False) media_url, video_id, preference=-1, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
else: else:
f = { f = {
'url': media_url, 'url': media_url,

View file

@ -56,10 +56,8 @@ class DCNBaseIE(InfoExtractor):
m3u8_url = self._html_search_regex( m3u8_url = self._html_search_regex(
r'file\s*:\s*"([^"]+)', webpage, 'm3u8 url', fatal=False) r'file\s*:\s*"([^"]+)', webpage, 'm3u8 url', fatal=False)
if m3u8_url: if m3u8_url:
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', entry_protocol, m3u8_id='hls', fatal=None) m3u8_url, video_id, 'mp4', entry_protocol, m3u8_id='hls', fatal=None))
if m3u8_formats:
formats.extend(m3u8_formats)
rtsp_url = self._search_regex( rtsp_url = self._search_regex(
r'<a[^>]+href="(rtsp://[^"]+)"', webpage, 'rtsp url', fatal=False) r'<a[^>]+href="(rtsp://[^"]+)"', webpage, 'rtsp url', fatal=False)

View file

@ -65,18 +65,14 @@ class EitbIE(InfoExtractor):
if token_data: if token_data:
token = token_data.get('token') token = token_data.get('token')
if token: if token:
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
'%s?hdnts=%s' % (hls_url, token), video_id, m3u8_id='hls', fatal=False) '%s?hdnts=%s' % (hls_url, token), video_id, m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
hds_url = media.get('HDS_SURL') hds_url = media.get('HDS_SURL')
if hds_url: if hds_url:
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
'%s?hdcore=3.7.0' % hds_url.replace('euskalsvod', 'euskalvod'), '%s?hdcore=3.7.0' % hds_url.replace('euskalsvod', 'euskalvod'),
video_id, f4m_id='hds', fatal=False) video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
self._sort_formats(formats) self._sort_formats(formats)

View file

@ -151,11 +151,9 @@ class FunimationIE(InfoExtractor):
errors.append(format_url) errors.append(format_url)
continue continue
if determine_ext(format_url) == 'm3u8': if determine_ext(format_url) == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
format_url + auth_token, display_id, 'mp4', entry_protocol='m3u8_native', format_url + auth_token, display_id, 'mp4', entry_protocol='m3u8_native',
preference=preference, m3u8_id='%s-hls' % funimation_id, fatal=False) preference=preference, m3u8_id='%s-hls' % funimation_id, fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
tbr = int_or_none(self._search_regex( tbr = int_or_none(self._search_regex(
r'-(\d+)[Kk]', format_url, 'tbr', default=None)) r'-(\d+)[Kk]', format_url, 'tbr', default=None))

View file

@ -51,10 +51,8 @@ class FunnyOrDieIE(InfoExtractor):
formats = [] formats = []
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
bitrates = [int(bitrate) for bitrate in re.findall(r'[,/]v(\d+)[,/]', m3u8_url)] bitrates = [int(bitrate) for bitrate in re.findall(r'[,/]v(\d+)[,/]', m3u8_url)]
bitrates.sort() bitrates.sort()

View file

@ -369,11 +369,9 @@ class GloboIE(InfoExtractor):
resource_url = resource['url'] resource_url = resource['url']
signed_url = '%s?h=%s&k=%s' % (resource_url, signed_hash, 'flash') signed_url = '%s?h=%s&k=%s' % (resource_url, signed_hash, 'flash')
if resource_id.endswith('m3u8') or resource_url.endswith('.m3u8'): if resource_id.endswith('m3u8') or resource_url.endswith('.m3u8'):
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
signed_url, resource_id, 'mp4', entry_protocol='m3u8_native', signed_url, resource_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls', fatal=False) m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
formats.append({ formats.append({
'url': signed_url, 'url': signed_url,

View file

@ -55,9 +55,7 @@ class HotStarIE(InfoExtractor):
format_url = format_data['src'] format_url = format_data['src']
ext = determine_ext(format_url) ext = determine_ext(format_url)
if ext == 'm3u8': if ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats(format_url, video_id, 'mp4', m3u8_id='hls', fatal=False) formats.extend(self._extract_m3u8_formats(format_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif ext == 'f4m': elif ext == 'f4m':
# produce broken files # produce broken files
continue continue

View file

@ -129,14 +129,10 @@ class IGNIE(InfoExtractor):
formats = [] formats = []
m3u8_url = api_data['refs'].get('m3uUrl') m3u8_url = api_data['refs'].get('m3uUrl')
if m3u8_url: if m3u8_url:
m3u8_formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) formats.extend(self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
f4m_url = api_data['refs'].get('f4mUrl') f4m_url = api_data['refs'].get('f4mUrl')
if f4m_url: if f4m_url:
f4m_formats = self._extract_f4m_formats(f4m_url, video_id, f4m_id='hds', fatal=False) formats.extend(self._extract_f4m_formats(f4m_url, video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
for asset in api_data['assets']: for asset in api_data['assets']:
formats.append({ formats.append({
'url': asset['url'], 'url': asset['url'],

View file

@ -44,10 +44,8 @@ class JWPlatformIE(InfoExtractor):
source_url = self._proto_relative_url(source['file']) source_url = self._proto_relative_url(source['file'])
source_type = source.get('type') or '' source_type = source.get('type') or ''
if source_type == 'application/vnd.apple.mpegurl': if source_type == 'application/vnd.apple.mpegurl':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
source_url, video_id, 'mp4', 'm3u8_native', fatal=False) source_url, video_id, 'mp4', 'm3u8_native', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif source_type.startswith('audio'): elif source_type.startswith('audio'):
formats.append({ formats.append({
'url': source_url, 'url': source_url,

View file

@ -163,10 +163,8 @@ class KalturaIE(InfoExtractor):
m3u8_url = info['dataUrl'].replace('format/url', 'format/applehttp') m3u8_url = info['dataUrl'].replace('format/url', 'format/applehttp')
if referrer: if referrer:
m3u8_url += '?referrer=%s' % referrer m3u8_url += '?referrer=%s' % referrer
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, entry_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) m3u8_url, entry_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
self._check_formats(formats, entry_id) self._check_formats(formats, entry_id)
self._sort_formats(formats) self._sort_formats(formats)

View file

@ -110,23 +110,17 @@ class LivestreamIE(InfoExtractor):
smil_url = video_data.get('smil_url') smil_url = video_data.get('smil_url')
if smil_url: if smil_url:
smil_formats = self._extract_smil_formats(smil_url, video_id) formats.extend(self._extract_smil_formats(smil_url, video_id))
if smil_formats:
formats.extend(smil_formats)
m3u8_url = video_data.get('m3u8_url') m3u8_url = video_data.get('m3u8_url')
if m3u8_url: if m3u8_url:
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
f4m_url = video_data.get('f4m_url') f4m_url = video_data.get('f4m_url')
if f4m_url: if f4m_url:
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
f4m_url, video_id, f4m_id='hds', fatal=False) f4m_url, video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
self._sort_formats(formats) self._sort_formats(formats)
comments = [{ comments = [{
@ -158,17 +152,13 @@ class LivestreamIE(InfoExtractor):
formats = [] formats = []
smil_url = stream_info.get('play_url') smil_url = stream_info.get('play_url')
if smil_url: if smil_url:
smil_formats = self._extract_smil_formats(smil_url, broadcast_id) formats.extend(self._extract_smil_formats(smil_url, broadcast_id))
if smil_formats:
formats.extend(smil_formats)
entry_protocol = 'm3u8' if is_live else 'm3u8_native' entry_protocol = 'm3u8' if is_live else 'm3u8_native'
m3u8_url = stream_info.get('m3u8_url') m3u8_url = stream_info.get('m3u8_url')
if m3u8_url: if m3u8_url:
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, broadcast_id, 'mp4', entry_protocol, m3u8_id='hls', fatal=False) m3u8_url, broadcast_id, 'mp4', entry_protocol, m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
rtsp_url = stream_info.get('rtsp_url') rtsp_url = stream_info.get('rtsp_url')
if rtsp_url: if rtsp_url:
@ -293,10 +283,8 @@ class LivestreamOriginalIE(InfoExtractor):
m3u8_url = video_data.get('httpUrl') m3u8_url = video_data.get('httpUrl')
if m3u8_url: if m3u8_url:
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', entry_protocol, m3u8_id='hls', fatal=False) m3u8_url, video_id, 'mp4', entry_protocol, m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
rtsp_url = video_data.get('rtspUrl') rtsp_url = video_data.get('rtspUrl')
if rtsp_url: if rtsp_url:

View file

@ -68,13 +68,9 @@ class NBAIE(InfoExtractor):
if video_url.startswith('/'): if video_url.startswith('/'):
continue continue
if video_url.endswith('.m3u8'): if video_url.endswith('.m3u8'):
m3u8_formats = self._extract_m3u8_formats(video_url, video_id, m3u8_id='hls', fatal=False) formats.extend(self._extract_m3u8_formats(video_url, video_id, m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif video_url.endswith('.f4m'): elif video_url.endswith('.f4m'):
f4m_formats = self._extract_f4m_formats(video_url + '?hdcore=3.4.1.1', video_id, f4m_id='hds', fatal=False) formats.extend(self._extract_f4m_formats(video_url + '?hdcore=3.4.1.1', video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
else: else:
key = video_file.attrib.get('bitrate') key = video_file.attrib.get('bitrate')
format_info = { format_info = {

View file

@ -44,17 +44,11 @@ class OoyalaBaseIE(InfoExtractor):
urls.append(url) urls.append(url)
delivery_type = stream['delivery_type'] delivery_type = stream['delivery_type']
if delivery_type == 'hls' or '.m3u8' in url: if delivery_type == 'hls' or '.m3u8' in url:
m3u8_formats = self._extract_m3u8_formats(url, embed_code, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) formats.extend(self._extract_m3u8_formats(url, embed_code, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif delivery_type == 'hds' or '.f4m' in url: elif delivery_type == 'hds' or '.f4m' in url:
f4m_formats = self._extract_f4m_formats(url, embed_code, f4m_id='hds', fatal=False) formats.extend(self._extract_f4m_formats(url, embed_code, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
elif '.smil' in url: elif '.smil' in url:
smil_formats = self._extract_smil_formats(url, embed_code, fatal=False) formats.extend(self._extract_smil_formats(url, embed_code, fatal=False))
if smil_formats:
formats.extend(smil_formats)
else: else:
formats.append({ formats.append({
'url': url, 'url': url,

View file

@ -116,17 +116,13 @@ class RaiTVIE(InfoExtractor):
ext = determine_ext(media_url) ext = determine_ext(media_url)
content_type = xpath_text(element, 'content-type') content_type = xpath_text(element, 'content-type')
if ext == 'm3u8': if ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
media_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', media_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls',
fatal=False) fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif ext == 'f4m': elif ext == 'f4m':
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
media_url + '?hdcore=3.7.0&plugin=aasp-3.7.0.39.44', media_url + '?hdcore=3.7.0&plugin=aasp-3.7.0.39.44',
video_id, f4m_id='hds', fatal=False) video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
elif ext == 'stl': elif ext == 'stl':
has_subtitle = True has_subtitle = True
elif content_type.startswith('video/'): elif content_type.startswith('video/'):

View file

@ -58,15 +58,11 @@ class RutubeIE(InfoExtractor):
for format_id, format_url in options['video_balancer'].items(): for format_id, format_url in options['video_balancer'].items():
ext = determine_ext(format_url) ext = determine_ext(format_url)
if ext == 'm3u8': if ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
format_url, video_id, 'mp4', m3u8_id=format_id, fatal=False) format_url, video_id, 'mp4', m3u8_id=format_id, fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif ext == 'f4m': elif ext == 'f4m':
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
format_url, video_id, f4m_id=format_id, fatal=False) format_url, video_id, f4m_id=format_id, fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
else: else:
formats.append({ formats.append({
'url': format_url, 'url': format_url,

View file

@ -63,15 +63,11 @@ class RuutuIE(InfoExtractor):
processed_urls.append(video_url) processed_urls.append(video_url)
ext = determine_ext(video_url) ext = determine_ext(video_url)
if ext == 'm3u8': if ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
video_url, video_id, 'mp4', m3u8_id='hls', fatal=False) video_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif ext == 'f4m': elif ext == 'f4m':
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
video_url, video_id, f4m_id='hds', fatal=False) video_url, video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
else: else:
proto = compat_urllib_parse_urlparse(video_url).scheme proto = compat_urllib_parse_urlparse(video_url).scheme
if not child.tag.startswith('HTTP') and proto != 'rtmp': if not child.tag.startswith('HTTP') and proto != 'rtmp':

View file

@ -57,9 +57,7 @@ class Tele13IE(InfoExtractor):
if format_url and format_url not in urls: if format_url and format_url not in urls:
ext = determine_ext(format_url) ext = determine_ext(format_url)
if ext == 'm3u8': if ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats(format_url, display_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) formats.extend(self._extract_m3u8_formats(format_url, display_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif YoutubeIE.suitable(format_url): elif YoutubeIE.suitable(format_url):
return self.url_result(format_url, 'Youtube') return self.url_result(format_url, 'Youtube')
else: else:

View file

@ -132,13 +132,11 @@ class ToggleIE(InfoExtractor):
vid_format = vid_format.replace(' ', '') vid_format = vid_format.replace(' ', '')
# if geo-restricted, m3u8 is inaccessible, but mp4 is okay # if geo-restricted, m3u8 is inaccessible, but mp4 is okay
if ext == 'm3u8': if ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
video_url, video_id, ext='mp4', m3u8_id=vid_format, video_url, video_id, ext='mp4', m3u8_id=vid_format,
note='Downloading %s m3u8 information' % vid_format, note='Downloading %s m3u8 information' % vid_format,
errnote='Failed to download %s m3u8 information' % vid_format, errnote='Failed to download %s m3u8 information' % vid_format,
fatal=False) fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif ext in ('mp4', 'wvm'): elif ext in ('mp4', 'wvm'):
# wvm are drm-protected files # wvm are drm-protected files
formats.append({ formats.append({

View file

@ -151,10 +151,8 @@ class VGTVIE(XstreamIE):
hls_url = streams.get('hls') hls_url = streams.get('hls')
if hls_url: if hls_url:
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
hls_url, video_id, 'mp4', m3u8_id='hls', fatal=False) hls_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
hds_url = streams.get('hds') hds_url = streams.get('hds')
if hds_url: if hds_url:

View file

@ -277,11 +277,9 @@ class VikiIE(VikiBaseIE):
r'^(\d+)[pP]$', format_id, 'height', default=None)) r'^(\d+)[pP]$', format_id, 'height', default=None))
for protocol, format_dict in stream_dict.items(): for protocol, format_dict in stream_dict.items():
if format_id == 'm3u8': if format_id == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
format_dict['url'], video_id, 'mp4', 'm3u8_native', format_dict['url'], video_id, 'mp4', 'm3u8_native',
m3u8_id='m3u8-%s' % protocol, fatal=False) m3u8_id='m3u8-%s' % protocol, fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
else: else:
formats.append({ formats.append({
'url': format_dict['url'], 'url': format_dict['url'],

View file

@ -437,10 +437,8 @@ class VimeoIE(VimeoBaseInfoExtractor):
}) })
m3u8_url = config_files.get('hls', {}).get('url') m3u8_url = config_files.get('hls', {}).get('url')
if m3u8_url: if m3u8_url:
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
# Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps # Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps
# at the same time without actual units specified. This lead to wrong sorting. # at the same time without actual units specified. This lead to wrong sorting.
self._sort_formats(formats, field_preference=('preference', 'height', 'width', 'fps', 'format_id')) self._sort_formats(formats, field_preference=('preference', 'height', 'width', 'fps', 'format_id'))

View file

@ -157,16 +157,12 @@ class WDRIE(InfoExtractor):
preference = qualities(['S', 'M', 'L', 'XL']) preference = qualities(['S', 'M', 'L', 'XL'])
if video_url.endswith('.f4m'): if video_url.endswith('.f4m'):
f4m_formats = self._extract_f4m_formats(video_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18', page_id, f4m_id='hds', fatal=False) formats.extend(self._extract_f4m_formats(video_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18', page_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
elif video_url.endswith('.smil'): elif video_url.endswith('.smil'):
smil_formats = self._extract_smil_formats(video_url, page_id, False, { formats.extend(self._extract_smil_formats(video_url, page_id, False, {
'hdcore': '3.3.0', 'hdcore': '3.3.0',
'plugin': 'aasp-3.3.0.99.43', 'plugin': 'aasp-3.3.0.99.43',
}) }))
if smil_formats:
formats.extend(smil_formats)
else: else:
formats.append({ formats.append({
'url': video_url, 'url': video_url,
@ -177,9 +173,7 @@ class WDRIE(InfoExtractor):
m3u8_url = self._search_regex(r'rel="adaptiv"[^>]+href="([^"]+)"', webpage, 'm3u8 url', default=None) m3u8_url = self._search_regex(r'rel="adaptiv"[^>]+href="([^"]+)"', webpage, 'm3u8 url', default=None)
if m3u8_url: if m3u8_url:
m3u8_formats = self._extract_m3u8_formats(m3u8_url, page_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False) formats.extend(self._extract_m3u8_formats(m3u8_url, page_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
direct_urls = re.findall(r'rel="web(S|M|L|XL)"[^>]+href="([^"]+)"', webpage) direct_urls = re.findall(r'rel="web(S|M|L|XL)"[^>]+href="([^"]+)"', webpage)
if direct_urls: if direct_urls:

View file

@ -125,20 +125,14 @@ class ZDFIE(InfoExtractor):
if ext == 'meta': if ext == 'meta':
continue continue
elif ext == 'smil': elif ext == 'smil':
smil_formats = self._extract_smil_formats( formats.extend(self._extract_smil_formats(
video_url, video_id, fatal=False) video_url, video_id, fatal=False))
if smil_formats:
formats.extend(smil_formats)
elif ext == 'm3u8': elif ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
video_url, video_id, 'mp4', m3u8_id='hls', fatal=False) video_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
if m3u8_formats:
formats.extend(m3u8_formats)
elif ext == 'f4m': elif ext == 'f4m':
f4m_formats = self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
video_url, video_id, f4m_id='hds', fatal=False) video_url, video_id, f4m_id='hds', fatal=False))
if f4m_formats:
formats.extend(f4m_formats)
else: else:
proto = format_m.group('proto').lower() proto = format_m.group('proto').lower()