- if self._downloader.params.get('listformats', None):
- self._print_formats(formats)
- return
-
- req_format = self._downloader.params.get('format', None)
- self.to_screen(u'Format: %s' % req_format)
-
- if req_format is None or req_format == 'best':
- return [formats[0]]
- elif req_format == 'worst':
- return [formats[-1]]
- elif req_format in ('-1', 'all'):
- return formats
- else:
- format = self._specific( req_format, formats )
- if format is None:
- raise ExtractorError(u'Requested format not available')
- return [format]
+ # Sort and remove doubles
+ formats.sort(key=lambda format: list(map(lambda s: s.zfill(6), format['format'].split('-'))))
+ for i in range(len(formats)-1,0,-1):
+ if formats[i]['format_id'] == formats[i-1]['format_id']:
+ del formats[i]
+
+ return {
+ 'id': video_id,
+ 'uploader': video_uploader,
+ 'upload_date': upload_date,
+ 'title': video_title,
+ 'thumbnail': thumbnail,
+ 'description': video_description,
+ 'age_limit': age_limit,
+ 'formats': formats,
+ }