aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeodarZ <neodarz@neodarz.net>2017-10-15 14:38:33 +0200
committerNeodarZ <neodarz@neodarz.net>2017-10-15 14:38:33 +0200
commit33cafb994b9f66e6e095cc72307bff5bce0da29b (patch)
tree07b15fa9ff4acbf8a1512f146383ab5252ea6968
parent58f5a092be9509212a9af82f34a899a9b417c78b (diff)
downloadconvert.py-33cafb994b9f66e6e095cc72307bff5bce0da29b.tar.xz
convert.py-33cafb994b9f66e6e095cc72307bff5bce0da29b.zip
Add multi extension support. Added mkv and webm
-rwxr-xr-xconvert.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/convert.py b/convert.py
index 0316127..881aa76 100755
--- a/convert.py
+++ b/convert.py
@@ -53,16 +53,17 @@ count = 0
for file in sorted(os.listdir(sourcedir)):
try:
name = file[:file.rfind(".")]
- if file.endswith(".mp4"):
+ ext = [".mp4", ".mkv", ".webm"]
+ if file.endswith(tuple(ext)):
exist = False
if os.path.isfile(outdir+"/"+name+".mp3"):
- if os.path.getsize(path_rm_end_slash(sourcedir)+"/"+name+".mp4") == os.path.getsize(outdir+"/"+name+".mp3"):
+ if os.path.getsize(path_rm_end_slash(sourcedir)+"/"+file) == os.path.getsize(outdir+"/"+name+".mp3"):
print("File "+path_rm_end_slash(sourcedir)+"/"+name+".mp3 already exist. Use -y for overwrite.")
else:
- print("Converting : "+name)
+ print("Converting : "+file)
count += 1
#cmd = ["ffmpeg", "-n", "-i", sourcedir+"/"+name+".mp4", "-c:a", "libmp3lame", outdir+"/"+name+".mp3"]²
- cmd = "ffmpeg "+arg+" -i '"+path_rm_end_slash(sourcedir)+"/"+name+".mp4' -c:a libmp3lame '"+outdir+"/"+name+".mp3'"
+ cmd = "ffmpeg "+arg+" -i '"+path_rm_end_slash(sourcedir)+"/"+file+"' -c:a libmp3lame '"+outdir+"/"+name+".mp3'"
thread = pexpect.spawn(cmd)
cpl = thread.compile_pattern_list([pexpect.EOF,"frame= *\d+",'(.+)'])