1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-10 19:37:25 +00:00

[viewster] extract more metadata for http formats

This commit is contained in:
remitamine 2016-04-26 13:39:53 +01:00
parent c9fd530670
commit f1f879098a

View File

@ -118,6 +118,7 @@ class ViewsterIE(InfoExtractor):
formats = [] formats = []
manifest_url = None manifest_url = None
m3u8_formats = []
for media_type in ('application/f4m+xml', 'application/x-mpegURL', 'video/mp4'): for media_type in ('application/f4m+xml', 'application/x-mpegURL', 'video/mp4'):
media = self._download_json( media = self._download_json(
'https://public-api.viewster.com/movies/%s/video?mediaType=%s' 'https://public-api.viewster.com/movies/%s/video?mediaType=%s'
@ -154,18 +155,32 @@ class ViewsterIE(InfoExtractor):
'qualities', default=None) 'qualities', default=None)
if not qualities: if not qualities:
continue continue
qualities = qualities.strip(',').split(',') qualities = list(map(lambda q: int(q[:-1]), qualities.strip(',').split(',')))
http_template = re.sub(QUALITIES_RE, r'%s', qualities_basename) qualities.sort()
http_template = re.sub(QUALITIES_RE, r'%dk', qualities_basename)
http_url_basename = url_basename(video_url) http_url_basename = url_basename(video_url)
for q in qualities: if m3u8_formats:
tbr = int_or_none(self._search_regex( self._sort_formats(m3u8_formats)
r'(\d+)k', q, 'bitrate', default=None)) m3u8_formats = list(filter(
formats.append({ lambda f: f.get('vcodec') != 'none' and f.get('resolution') != 'multiple',
'url': video_url.replace(http_url_basename, http_template % q), m3u8_formats))
'ext': 'mp4', if len(qualities) == len(m3u8_formats):
'format_id': 'http' + ('-%d' % tbr if tbr else ''), for q, m3u8_format in zip(qualities, m3u8_formats):
'tbr': tbr, f = m3u8_format.copy()
}) f.update({
'url': video_url.replace(http_url_basename, http_template % q),
'format_id': f['format_id'].replace('hls', 'http'),
'protocol': 'http',
})
formats.append(f)
else:
for q in qualities:
formats.append({
'url': video_url.replace(http_url_basename, http_template % q),
'ext': 'mp4',
'format_id': 'http-%d' % q,
'tbr': q,
})
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()