projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
21f6330
)
[utils] Improve prepend_extension
author
Sergey M․
<dstftw@gmail.com>
Sat, 2 May 2015 17:06:01 +0000
(23:06 +0600)
committer
Sergey M․
<dstftw@gmail.com>
Sat, 2 May 2015 17:06:01 +0000
(23:06 +0600)
Now `ext` is appended to filename if real extension != expected extension.
youtube_dl/utils.py
patch
|
blob
|
history
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index f07679c76458947569fb7c33dd16eead1324e48e..b3abfbc11b8ac5f9d036ad04800c820337252da8 100644
(file)
--- 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=[]):