aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-05-02 23:23:06 +0600
committerSergey M․ <dstftw@gmail.com>2015-05-02 23:23:06 +0600
commitb3ed15b7604ce83e85b791ed329c5725a436b805 (patch)
treef10ae77994c6eaa011cdfb3be62f490e1d930dd1 /youtube_dl/utils.py
parent666a9a2b954bb6c75a5fcdb9fbb18842038c188a (diff)
[utils] Add replace_extension
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index b3abfbc11..a5a5c317e 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1357,6 +1357,13 @@ def prepend_extension(filename, ext, expected_real_ext=None):
else '{0}.{1}'.format(filename, ext))
+def replace_extension(filename, ext, expected_real_ext=None):
+ name, real_ext = os.path.splitext(filename)
+ return '{0}.{1}'.format(
+ name if not expected_real_ext or real_ext[1:] == expected_real_ext else filename,
+ ext)
+
+
def check_executable(exe, args=[]):
""" Checks if the given binary is installed somewhere in PATH, and returns its name.
args can be a list of arguments for a short output (like -version) """