[escapist] Fix formats extraction

This commit is contained in:
Sergey M․ 2015-05-04 18:59:22 +06:00
parent b9b3ab45ea
commit 71fa56b887

View File

@ -8,7 +8,7 @@ from ..compat import compat_urllib_request
from ..utils import ( from ..utils import (
determine_ext, determine_ext,
clean_html, clean_html,
qualities, int_or_none,
) )
@ -72,28 +72,23 @@ class EscapistIE(InfoExtractor):
video_id = imsVideo['videoID'] video_id = imsVideo['videoID']
key = imsVideo['hash'] key = imsVideo['hash']
quality = qualities(['lq', 'hq', 'hd'])
formats = []
for q in ['lq', 'hq', 'hd']:
config_req = compat_urllib_request.Request( config_req = compat_urllib_request.Request(
'http://www.escapistmagazine.com/videos/' 'http://www.escapistmagazine.com/videos/'
'vidconfig.php?videoID=%s&hash=%s&quality=%s' % (video_id, key, 'mp4_' + q)) 'vidconfig.php?videoID=%s&hash=%s' % (video_id, key))
config_req.add_header('Referer', url) config_req.add_header('Referer', url)
config = self._download_webpage(config_req, video_id, 'Downloading video config ' + q.upper()) config = self._download_webpage(config_req, video_id, 'Downloading video config')
data = json.loads(_decrypt_config(key, config)) data = json.loads(_decrypt_config(key, config))
title = clean_html(data['videoData']['title']) title = clean_html(data['videoData']['title'])
duration = data['videoData']['duration'] / 1000 duration = data['videoData']['duration'] / 1000
for i, v in enumerate(data['files']['videos']): formats = [{
'url': video['src'],
formats.append({ 'format_id': '%s-%sp' % (determine_ext(video['src']), video['res']),
'url': v, 'height': int_or_none(video.get('res')),
'format_id': determine_ext(v) + '_' + q + str(i), } for video in data['files']['videos']]
'quality': quality(q), self._sort_formats(formats)
})
return { return {
'id': video_id, 'id': video_id,