aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-11-02 10:50:30 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-11-02 10:50:30 +0100
commit9580711841d60426e2b888cde7b410ae7d512849 (patch)
tree4860d80fd274a0ea0c26f605534d8875c23a9915 /youtube_dl/utils.py
parentc30ae9594cea215f36a736f944acd67fcec39d0d (diff)
downloadyoutube-dl-9580711841d60426e2b888cde7b410ae7d512849.tar.xz
[ffmpeg] Move version detection to utils
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 2864e5142..fcfdadeb6 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1472,6 +1472,25 @@ def check_executable(exe, args=[]):
return exe
+def get_exe_version(exe, args=['--version'],
+ version_re=r'version\s+([0-9._-a-zA-Z]+)',
+ unrecognized=u'present'):
+ """ Returns the version of the specified executable,
+ or False if the executable is not present """
+ try:
+ out, err = subprocess.Popen(
+ [exe] + args,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
+ except OSError:
+ return False
+ firstline = out.partition(b'\n')[0].decode('ascii', 'ignore')
+ m = re.search(version_re, firstline)
+ if m:
+ return m.group(1)
+ else:
+ return unrecognized
+
+
class PagedList(object):
def __len__(self):
# This is only useful for tests