Merge branch 'master' into prefer-webm
[youtube-dl] / youtube-dl
index f8271a7fe688c1c38020c3ecbf2a62fa4a6bc69f..0c1209a04e88c5e5c7f861c8a46f44dbf9f7cada 100755 (executable)
@@ -864,7 +864,7 @@ class YoutubeIE(InfoExtractor):
        _AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en'
        _NETRC_MACHINE = 'youtube'
        # Listed in order of quality
-       _available_formats = ['38', '37', '22', '45', '35', '34', '43', '18', '6', '5', '17', '13']
+       _available_formats = ['38', '37', '45', '22', '43', '35', '34', '18', '6', '5', '17', '13']
        _video_extensions = {
                '13': '3gp',
                '17': 'mp4',
@@ -2619,10 +2619,13 @@ class FFmpegExtractAudioPP(PostProcessor):
 
        @staticmethod
        def get_audio_codec(path):
-               handle = subprocess.Popen(['ffprobe', '-show_streams', path],
-                               stderr=file(os.path.devnull, 'w'), stdout=subprocess.PIPE)
-               output = handle.communicate()[0]
-               if handle.wait() != 0:
+               try:
+                       handle = subprocess.Popen(['ffprobe', '-show_streams', '--', path],
+                                       stderr=file(os.path.devnull, 'w'), stdout=subprocess.PIPE)
+                       output = handle.communicate()[0]
+                       if handle.wait() != 0:
+                               return None
+               except (IOError, OSError):
                        return None
                audio_codec = None
                for line in output.split('\n'):
@@ -2635,7 +2638,7 @@ class FFmpegExtractAudioPP(PostProcessor):
        @staticmethod
        def run_ffmpeg(path, out_path, codec, more_opts):
                try:
-                       ret = subprocess.call(['ffmpeg', '-y', '-i', path, '-vn', '-acodec', codec] + more_opts + [out_path],
+                       ret = subprocess.call(['ffmpeg', '-y', '-i', path, '-vn', '-acodec', codec] + more_opts + ['--', out_path],
                                        stdout=file(os.path.devnull, 'w'), stderr=subprocess.STDOUT)
                        return (ret == 0)
                except (IOError, OSError):
@@ -2646,7 +2649,7 @@ class FFmpegExtractAudioPP(PostProcessor):
 
                filecodec = self.get_audio_codec(path)
                if filecodec is None:
-                       self._downloader.to_stderr(u'WARNING: no audio codec found in file')
+                       self._downloader.to_stderr(u'WARNING: unable to obtain file audio codec with ffprobe')
                        return None
 
                more_opts = []
@@ -2676,7 +2679,7 @@ class FFmpegExtractAudioPP(PostProcessor):
                status = self.run_ffmpeg(path, new_path, acodec, more_opts)
 
                if not status:
-                       self._downloader.to_stderr(u'WARNING: error running ffmpeg' % ret)
+                       self._downloader.to_stderr(u'WARNING: error running ffmpeg')
                        return None
 
                try:
@@ -2720,7 +2723,7 @@ if __name__ == '__main__':
                # Parse command line
                parser = optparse.OptionParser(
                        usage='Usage: %prog [options] url...',
-                       version='2011.02.25',
+                       version='2011.02.25c',
                        conflict_handler='resolve',
                )