summaryrefslogtreecommitdiff
path: root/convert.py
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
commiteeaf382d813ad0ea7768cf4a9b169e702ee097a5 (patch)
tree9323777955d18216717b7a823a9f3e3bb28b7e55 /convert.py
parentcb498521fcb38a9cca2d8b6d481e0063eeb1c91c (diff)
downloadvideo_save-eeaf382d813ad0ea7768cf4a9b169e702ee097a5.tar.xz
video_save-eeaf382d813ad0ea7768cf4a9b169e702ee097a5.zip
Fix bug with end slash in source dir path
Diffstat (limited to '')
-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+",'(.+)'])