[adobetv] extract AdobeTVVideo info from json directly

pull/8/head
remitamine 9 years ago
parent 30bd1c16c8
commit 402ca40c9d

@ -10,6 +10,7 @@ from ..utils import (
int_or_none, int_or_none,
float_or_none, float_or_none,
ISO639Utils, ISO639Utils,
determine_ext,
) )
@ -79,28 +80,25 @@ class AdobeTVVideoIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
video_data = self._download_json(url + '?format=json', video_id)
webpage = self._download_webpage(url, video_id)
player_params = self._parse_json(self._search_regex(
r'var\s+bridge\s*=\s*([^;]+);', webpage, 'player parameters'),
video_id)
formats = [{ formats = [{
'format_id': '%s-%s' % (determine_ext(source['src']), source.get('height')),
'url': source['src'], 'url': source['src'],
'width': source.get('width'), 'width': int_or_none(source.get('width')),
'height': source.get('height'), 'height': int_or_none(source.get('height')),
'tbr': source.get('bitrate'), 'tbr': int_or_none(source.get('bitrate')),
} for source in player_params['sources']] } for source in video_data['sources']]
self._sort_formats(formats)
# For both metadata and downloaded files the duration varies among # For both metadata and downloaded files the duration varies among
# formats. I just pick the max one # formats. I just pick the max one
duration = max(filter(None, [ duration = max(filter(None, [
float_or_none(source.get('duration'), scale=1000) float_or_none(source.get('duration'), scale=1000)
for source in player_params['sources']])) for source in video_data['sources']]))
subtitles = {} subtitles = {}
for translation in player_params.get('translations', []): for translation in video_data.get('translations', []):
lang_id = translation.get('language_w3c') or ISO639Utils.long2short(translation['language_medium']) lang_id = translation.get('language_w3c') or ISO639Utils.long2short(translation['language_medium'])
if lang_id not in subtitles: if lang_id not in subtitles:
subtitles[lang_id] = [] subtitles[lang_id] = []
@ -112,8 +110,9 @@ class AdobeTVVideoIE(InfoExtractor):
return { return {
'id': video_id, 'id': video_id,
'formats': formats, 'formats': formats,
'title': player_params['title'], 'title': video_data['title'],
'description': self._og_search_description(webpage), 'description': video_data.get('description'),
'thumbnail': video_data['video'].get('poster'),
'duration': duration, 'duration': duration,
'subtitles': subtitles, 'subtitles': subtitles,
} }

Loading…
Cancel
Save