From 533633c71698f685ca33c419b521881e88b4b4cd Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Fri, 22 Mar 2013 14:19:44 +0100 Subject: [PATCH] update youtube.py --- src/you_get/downloader/youtube.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/you_get/downloader/youtube.py b/src/you_get/downloader/youtube.py index 67f2096c..6ec39ccf 100644 --- a/src/you_get/downloader/youtube.py +++ b/src/you_get/downloader/youtube.py @@ -34,12 +34,13 @@ youtube_codecs = [ def parse_video_info(raw_info): """Parser for YouTube's get_video_info data. - Returns a map, with 'url_encoded_fmt_stream_map' field being a sorted list. + Returns a dict, where 'url_encoded_fmt_stream_map' maps to a sorted list. """ # Percent-encoding reserved characters, used as separators. - separator = { + sepr = { '&': '%26', + ',': '%2C', '=': '%3D', } @@ -53,17 +54,20 @@ def parse_video_info(raw_info): youtube_codecs], range(len(youtube_codecs)))) + # {key1: value1, key2: value2, ..., + # 'url_encoded_fmt_stream_map': [{'itag': '38', ...}, ...] + # } return dict( [(lambda metadata: ['url_encoded_fmt_stream_map', ( - lambda url_encoded_fmt_stream_map: + lambda stream_map: sorted( [dict( - [sub_item.split(separator['=']) - for sub_item in - item.split(separator['&'])]) + [subitem.split(sepr['=']) + for subitem in + item.split(sepr['&'])]) for item in - url_encoded_fmt_stream_map.split('%2C')], + stream_map.split(sepr[','])], key = lambda stream: fmt_level[stream['itag']]))