mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-20 20:14:24 +00:00
[utils] Improve prepend_extension
Now `ext` is appended to filename if real extension != expected extension.
This commit is contained in:
parent
21f6330274
commit
e65e4c8874
@ -1349,9 +1349,12 @@ def parse_duration(s):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def prepend_extension(filename, ext):
|
def prepend_extension(filename, ext, expected_real_ext=None):
|
||||||
name, real_ext = os.path.splitext(filename)
|
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=[]):
|
def check_executable(exe, args=[]):
|
||||||
|
Loading…
Reference in New Issue
Block a user