[letv] Reduce duplicated codes

master
Yen Chi Hsuan 2016-01-20 03:17:35 +08:00
parent 78be2eca7c
commit 10defdd06a
1 changed files with 11 additions and 8 deletions

View File

@ -281,14 +281,17 @@ class LetvCloudIE(InfoExtractor):
"uu=" + uu + "&vu=" + vu) "uu=" + uu + "&vu=" + vu)
play_json = self._download_json(play_json_req, media_id, 'Downloading playJson data') play_json = self._download_json(play_json_req, media_id, 'Downloading playJson data')
formats = [{ formats = []
'url': base64.b64decode(media['play_url']['main_url'].encode('utf-8')).decode("utf-8"), for media in play_json['data']['video_info']['media'].values():
'ext': 'mp4', play_url = media['play_url']
'format_id': int_or_none(media.get('play_url', {}).get('vtype')), formats.append({
'format_note': str_or_none(media.get('play_url', {}).get('definition')), 'url': base64.b64decode(play_url['main_url'].encode('utf-8')).decode("utf-8"),
'width': int_or_none(media.get('play_url', {}).get('vwidth')), 'ext': 'mp4',
'height': int_or_none(media.get('play_url', {}).get('vheight')), 'format_id': int_or_none(play_url.get('vtype')),
} for media in play_json['data']['video_info']['media'].values()] 'format_note': str_or_none(play_url.get('definition')),
'width': int_or_none(play_url.get('vwidth')),
'height': int_or_none(play_url.get('vheight')),
})
self._sort_formats(formats) self._sort_formats(formats)
return { return {