[viewster] improve http formats extraction

This commit is contained in:
remitamine 2016-04-24 14:33:47 +01:00
parent 03dd60ca41
commit c14dc00df3

View File

@ -146,21 +146,26 @@ class ViewsterIE(InfoExtractor):
qualities_basename = self._search_regex( qualities_basename = self._search_regex(
'/([^/]+)\.csmil/', '/([^/]+)\.csmil/',
manifest_url, 'qualities basename', default=None) manifest_url, 'qualities basename', default=None)
if qualities_basename: if not qualities_basename:
QUALITIES_RE = r'((,\d+k)+,?)' continue
qualities = self._search_regex( QUALITIES_RE = r'((,\d+k)+,?)'
QUALITIES_RE, qualities_basename, qualities = self._search_regex(
'qualities').strip(',').split(',') QUALITIES_RE, qualities_basename,
http_template = re.sub(QUALITIES_RE, r'%s', qualities_basename) 'qualities', default=None)
http_url_basename = url_basename(video_url) if not qualities:
for q in qualities: continue
formats.append({ qualities = qualities.strip(',').split(',')
'url': video_url.replace(http_url_basename, http_template % q), http_template = re.sub(QUALITIES_RE, r'%s', qualities_basename)
'ext': 'mp4', http_url_basename = url_basename(video_url)
'format_id': 'http-%s' % q, for q in qualities:
'tbr': int_or_none(self._search_regex( tbr = int_or_none(self._search_regex(
r'(\d+)k', q, 'bitrate', default=None)), r'(\d+)k', q, 'bitrate', default=None))
}) formats.append({
'url': video_url.replace(http_url_basename, http_template % q),
'ext': 'mp4',
'format_id': 'http' + ('-%d' % tbr if tbr else ''),
'tbr': tbr,
})
if not formats and not info.get('LanguageSets') and not info.get('VODSettings'): if not formats and not info.get('LanguageSets') and not info.get('VODSettings'):
self.raise_geo_restricted() self.raise_geo_restricted()