]> Raphaƫl G. Git Repositories - youtubedl/blobdiff - youtube_dl/downloader/rtmp.py
Merge tag 'upstream/2014.11.21'
[youtubedl] / youtube_dl / downloader / rtmp.py
index cc6a84106b4ccc1221b74da313eb619544c4a8ef..17d9631faa54613dcd8c910231a428cad2389c60 100644 (file)
@@ -8,12 +8,19 @@ import time
 
 from .common import FileDownloader
 from ..utils import (
 
 from .common import FileDownloader
 from ..utils import (
+    check_executable,
+    compat_str,
     encodeFilename,
     format_bytes,
     encodeFilename,
     format_bytes,
-    compat_str,
+    get_exe_version,
 )
 
 
 )
 
 
+def rtmpdump_version():
+    return get_exe_version(
+        'rtmpdump', ['--help'], r'(?i)RTMPDump\s*v?([0-9a-zA-Z._-]+)')
+
+
 class RtmpFD(FileDownloader):
     def real_download(self, filename, info_dict):
         def run_rtmpdump(args):
 class RtmpFD(FileDownloader):
     def real_download(self, filename, info_dict):
         def run_rtmpdump(args):
@@ -103,10 +110,8 @@ class RtmpFD(FileDownloader):
         test = self.params.get('test', False)
 
         # Check for rtmpdump first
         test = self.params.get('test', False)
 
         # Check for rtmpdump first
-        try:
-            subprocess.call(['rtmpdump', '-h'], stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT)
-        except (OSError, IOError):
-            self.report_error('RTMP download detected but "rtmpdump" could not be run')
+        if not check_executable('rtmpdump', ['-h']):
+            self.report_error('RTMP download detected but "rtmpdump" could not be run. Please install it.')
             return False
 
         # Download using rtmpdump. rtmpdump returns exit code 2 when
             return False
 
         # Download using rtmpdump. rtmpdump returns exit code 2 when