X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2FYoutubeDL.py;h=0fdcf1b0b724c9ddd0a04421967bf20f8718933b;hb=9dd8e46a2d0860421b4bb4f616f05e5ebd686380;hp=e5d497b3f2ff64964cca844141f605cdb9b653b2;hpb=feccf29c876869f44a9c983977371073b9801a51;p=youtube-dl.git diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index e5d497b3f..0fdcf1b0b 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1092,7 +1092,7 @@ class YoutubeDL(object): req_format = self.params.get('format') if req_format is None: req_format_list = [] - if info_dict['extractor'] == 'youtube' and FFmpegMergerPP(self).available: + if info_dict['extractor'] in ['youtube', 'ted'] and FFmpegMergerPP(self).available: req_format_list.append('bestvideo+bestaudio') req_format_list.append('best') req_format = '/'.join(req_format_list) @@ -1373,12 +1373,33 @@ class YoutubeDL(object): ' The formats won\'t be merged') else: postprocessors = [merger] + + def compatible_formats(formats): + video, audio = formats + # Check extension + video_ext, audio_ext = audio.get('ext'), video.get('ext') + if video_ext and audio_ext: + COMPATIBLE_EXTS = ( + ('mp3', 'mp4', 'm4a', 'm4p', 'm4b', 'm4r', 'm4v'), + ('webm') + ) + for exts in COMPATIBLE_EXTS: + if video_ext in exts and audio_ext in exts: + return True + # TODO: Check acodec/vcodec + return False + + requested_formats = info_dict['requested_formats'] + if self.params.get('merge_output_format') is None and not compatible_formats(requested_formats): + filename = os.path.splitext(filename)[0] + '.mkv' + self.report_warning('You have requested formats uncompatible for merge. ' + 'The formats will be merged into mkv') if os.path.exists(encodeFilename(filename)): self.to_screen( '[download] %s has already been downloaded and ' 'merged' % filename) else: - for f in info_dict['requested_formats']: + for f in requested_formats: new_info = dict(info_dict) new_info.update(f) fname = self.prepare_filename(new_info) @@ -1495,7 +1516,6 @@ class YoutubeDL(object): pps_chain.extend(ie_info['__postprocessors']) pps_chain.extend(self._pps) for pp in pps_chain: - old_filename = info['filepath'] try: files_to_delete, info = pp.run(info) except PostProcessingError as e: