X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=youtube_dl%2FYoutubeDL.py;h=633e3d8a141e2cd249a69da2137709f2f1858040;hb=b3a286d69d2bf28ba32a77b0fe66932eb6d1bc65;hp=c18ce9660711c7845b36e34285042d54a13f5072;hpb=6789defea9b1fc7ff631e9da8a281504167ced10;p=youtube-dl diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index c18ce9660..633e3d8a1 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -938,6 +938,9 @@ class YoutubeDL(object): def has_header(self, h): return h in self.headers + def get_header(self, h, default=None): + return self.headers.get(h, default) + pr = _PseudoRequest(info_dict['url']) self.cookiejar.add_cookie_header(pr) return pr.headers.get('Cookie') @@ -964,9 +967,11 @@ class YoutubeDL(object): thumbnails.sort(key=lambda t: ( t.get('preference'), t.get('width'), t.get('height'), t.get('id'), t.get('url'))) - for t in thumbnails: + for i, t in enumerate(thumbnails): if 'width' in t and 'height' in t: t['resolution'] = '%dx%d' % (t['width'], t['height']) + if t.get('id') is None: + t['id'] = '%d' % i if thumbnails and 'thumbnail' not in info_dict: info_dict['thumbnail'] = thumbnails[-1]['url'] @@ -1074,7 +1079,8 @@ class YoutubeDL(object): else self.params['merge_output_format']) selected_format = { 'requested_formats': formats_info, - 'format': rf, + 'format': '%s+%s' % (formats_info[0].get('format'), + formats_info[1].get('format')), 'format_id': '%s+%s' % (formats_info[0].get('format_id'), formats_info[1].get('format_id')), 'width': formats_info[0].get('width'),