aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-05-02 23:06:01 +0600
committerSergey M․ <dstftw@gmail.com>2015-05-02 23:06:01 +0600
commite65e4c88748f2d245aa683116a2c6de907186751 (patch)
treee811f6731bc4a505e8279afda4b67d31123f687e /youtube_dl/utils.py
parent21f6330274c6f87c796bd9248ed82d2bc73de969 (diff)
[utils] Improve prepend_extension
Now `ext` is appended to filename if real extension != expected extension.
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index f07679c76..b3abfbc11 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1349,9 +1349,12 @@ def parse_duration(s):
return res
-def prepend_extension(filename, ext):
+def prepend_extension(filename, ext, expected_real_ext=None):
name, real_ext = os.path.splitext(filename)
- return '{0}.{1}{2}'.format(name, ext, real_ext)
+ return (
+ '{0}.{1}{2}'.format(name, ext, real_ext)
+ if not expected_real_ext or real_ext[1:] == expected_real_ext
+ else '{0}.{1}'.format(filename, ext))
def check_executable(exe, args=[]):