X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=youtube_dl%2FPostProcessor.py;h=8868b37af6455523bad0fbf9a6702fd37e45d024;hb=3fc03845a1bd35a7756b0b2f009e70e7eeccbdf3;hp=545b6992b4c41c8cc59c260f6eb9faa21e14eb91;hpb=7851b37993ad2cb898ca76e34fade492dddeec59;p=youtube-dl diff --git a/youtube_dl/PostProcessor.py b/youtube_dl/PostProcessor.py index 545b6992b..8868b37af 100644 --- a/youtube_dl/PostProcessor.py +++ b/youtube_dl/PostProcessor.py @@ -85,8 +85,9 @@ class FFmpegPostProcessor(PostProcessor): p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout,stderr = p.communicate() if p.returncode != 0: + stderr = stderr.decode('utf-8', 'replace') msg = stderr.strip().split('\n')[-1] - raise FFmpegPostProcessorError(msg.decode('utf-8', 'replace')) + raise FFmpegPostProcessorError(msg) def _ffmpeg_filename_argument(self, fn): # ffmpeg broke --, see https://ffmpeg.org/trac/ffmpeg/ticket/2127 for details @@ -143,10 +144,10 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): more_opts = [] if self._preferredcodec == 'best' or self._preferredcodec == filecodec or (self._preferredcodec == 'm4a' and filecodec == 'aac'): - if self._preferredcodec == 'm4a' and filecodec == 'aac': + if filecodec == 'aac' and self._preferredcodec in ['m4a', 'best']: # Lossless, but in another container acodec = 'copy' - extension = self._preferredcodec + extension = 'm4a' more_opts = [self._exes['avconv'] and '-bsf:a' or '-absf', 'aac_adtstoasc'] elif filecodec in ['aac', 'mp3', 'vorbis', 'opus']: # Lossless if possible @@ -188,6 +189,11 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): prefix, sep, ext = path.rpartition(u'.') # not os.path.splitext, since the latter does not work on unicode in all setups new_path = prefix + sep + extension + + # If we download foo.mp3 and convert it to... foo.mp3, then don't delete foo.mp3, silly. + if new_path == path: + self._nopostoverwrites = True + try: if self._nopostoverwrites and os.path.exists(encodeFilename(new_path)): self._downloader.to_screen(u'[youtube] Post-process file %s exists, skipping' % new_path) @@ -210,7 +216,7 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): self._downloader.to_stderr(u'WARNING: Cannot update utime of audio file') information['filepath'] = new_path - return False,information + return self._nopostoverwrites,information class FFmpegVideoConvertor(FFmpegPostProcessor): def __init__(self, downloader=None,preferedformat=None):