aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorLucas <mikotosc@gmail.com>2015-09-28 22:00:56 +0200
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2015-10-31 15:18:23 +0100
commit892015b088fa21915270b0a05937fcc7063ccdd2 (patch)
tree52722a66d72d8e936981bca21e7f17638bd45885 /youtube_dl
parent47f2d01a5ac074f6959aa12e8bc00310f18a54e8 (diff)
replaced inefficient code
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/kika.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/youtube_dl/extractor/kika.py b/youtube_dl/extractor/kika.py
index db0f333ff..871e4ea44 100644
--- a/youtube_dl/extractor/kika.py
+++ b/youtube_dl/extractor/kika.py
@@ -87,29 +87,25 @@ class KikaIE(InfoExtractor):
format_dict['url'] = elem.find('progressiveDownloadUrl').text
format_dict['ext'] = elem.find('mediaType').text.lower()
format_dict['format'] = elem.find('profileName').text
- width = int(elem.find('frameWidth').text)
- height = int(elem.find('frameHeight').text)
- format_dict['width'] = width
- format_dict['height'] = height
- format_dict['resolution'] = '%dx%d' % (width, height)
+ format_dict['width'] = int(elem.find('frameWidth').text)
+ format_dict['height'] = int(elem.find('frameHeight').text)
+ format_dict['resolution'] = '%dx%d' % (format_dict['width'],
+ format_dict['height'])
format_dict['abr'] = int(elem.find('bitrateAudio').text)
format_dict['vbr'] = int(elem.find('bitrateVideo').text)
format_dict['tbr'] = format_dict['abr'] + format_dict['vbr']
format_dict['filesize'] = int(elem.find('fileSize').text)
- # append resolution and dict for sorting by resolution
- formats_list.append((width * height, format_dict))
+ formats_list.append(format_dict)
# Sort by resolution (=quality)
- formats_list.sort()
-
- out_list = [x[1] for x in formats_list]
+ formats_list.sort(key=lambda x: x['width'] * x['height'])
return {
'id': video_id,
'title': title,
'description': description,
- 'formats': out_list,
+ 'formats': formats_list,
'duration': duration,
'webpage_url': webpage_url
}