Correct detect_executables on Windows (Closes #447, #457)
authorPhilipp Hagemeister <phihag@phihag.de>
Mon, 8 Oct 2012 20:14:19 +0000 (22:14 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Mon, 8 Oct 2012 20:14:19 +0000 (22:14 +0200)
youtube_dl/PostProcessor.py

index 375da1aa3f08cf0fb9d9886ee1b6d4308d18c763..f2e2aa1fadf5e8c8c1962ef11851820802550ce0 100644 (file)
@@ -71,13 +71,14 @@ class FFmpegExtractAudioPP(PostProcessor):
 
        @staticmethod
        def detect_executables():
-               available = {'avprobe' : False, 'avconv' : False, 'ffmpeg' : False, 'ffprobe' : False}
-               for path in os.environ["PATH"].split(os.pathsep):
-                       for program in available.keys():
-                               exe_file = os.path.join(path, program)
-                               if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK):
-                                       available[program] = exe_file
-               return available
+               def executable(exe):
+                       try:
+                               subprocess.check_output([exe, '-version'])
+                       except OSError:
+                               return False
+                       return exe
+               programs = ['avprobe', 'avconv', 'ffmpeg', 'ffprobe']
+               return dict((program, executable(program)) for program in programs)
 
        def get_audio_codec(self, path):
                if not self._exes['ffprobe'] and not self._exes['avprobe']: return None