aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeodarZ <neodarz@neodarz.net>2017-10-15 13:53:27 +0200
committerNeodarZ <neodarz@neodarz.net>2017-10-15 13:53:27 +0200
commite3f3ddd59fb8ce9b9ca15b699ef08d985f684ec8 (patch)
tree052694d0aa0b12d4942d2034cea353d09e99f53e
parent4d4a44ffb2847072db016440412e1be9d3dee1d4 (diff)
downloadconvert.py-e3f3ddd59fb8ce9b9ca15b699ef08d985f684ec8.tar.xz
convert.py-e3f3ddd59fb8ce9b9ca15b699ef08d985f684ec8.zip
Fix bug with end slash in source dir path
-rwxr-xr-xconvert.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/convert.py b/convert.py
index 3b1db72..3951ab1 100755
--- a/convert.py
+++ b/convert.py
@@ -9,6 +9,10 @@ import pexpect
import time
import datetime
+def path_rm_end_slash(string):
+ string = re.sub("\/$", "", string)
+ return(string)
+
if len(sys.argv) >= 3 and len(sys.argv) <= 4:
if len(sys.argv) == 3:
sourcedir = sys.argv[1]
@@ -40,6 +44,9 @@ def dirSize(path,ext1,ext2):
count += 1
return count
+if not os.path.exists(outdir):
+ os.makedirs(outdir)
+
total = dirSize(sourcedir, ".mp4", ".mkv")
count = 0
@@ -49,13 +56,13 @@ for file in sorted(os.listdir(sourcedir)):
if file.endswith(".mp4"):
exist = False
if os.path.isfile(outdir+"/"+name+".mp3"):
- if os.path.getsize(sourcedir+"/"+name+".mp3") == os.path.getsize(outdir+"/"+name+".mp3"):
- print("File "+sourcedir+"/"+name+".mp3 already exist. Use -y for overwrite.")
+ if os.path.getsize(path_rm_end_slash(sourcedir)+"/"+name+".mp4") == 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)
count += 1
#cmd = ["ffmpeg", "-n", "-i", sourcedir+"/"+name+".mp4", "-c:a", "libmp3lame", outdir+"/"+name+".mp3"]²
- cmd = "ffmpeg "+arg+" -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'"
thread = pexpect.spawn(cmd)
cpl = thread.compile_pattern_list([pexpect.EOF,"frame= *\d+",'(.+)'])