From b541f0f1cb916c83d0565b3a1aa3e0ffb4356d21 Mon Sep 17 00:00:00 2001 From: NeodarZ Date: Sun, 15 Oct 2017 14:38:33 +0200 Subject: Add multi extension support. Added mkv and webm --- convert.py | 9 +++++---- 1 file 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+",'(.+)']) -- cgit v1.2.1