aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2017-07-12 14:53:04 +0200
committerneodarz <neodarz@neodarz.net>2017-07-12 14:53:04 +0200
commit4d4a44ffb2847072db016440412e1be9d3dee1d4 (patch)
tree11c5a9ce0c512fffad4d720ec7e10e96f904d4ba
parent0b9c1ce1e2f20b1519ba59785c3dad87127a7f28 (diff)
downloadconvert.py-4d4a44ffb2847072db016440412e1be9d3dee1d4.tar.xz
convert.py-4d4a44ffb2847072db016440412e1be9d3dee1d4.zip
Add function to know if file exist
-rwxr-xr-xconvert.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/convert.py b/convert.py
index 89dd19b..3b1db72 100755
--- a/convert.py
+++ b/convert.py
@@ -47,7 +47,12 @@ for file in sorted(os.listdir(sourcedir)):
try:
name = file[:file.rfind(".")]
if file.endswith(".mp4"):
- print("Converting : "+name)
+ 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.")
+ 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'"
@@ -77,7 +82,7 @@ for file in sorted(os.listdir(sourcedir)):
if re.match(r'.*time=.*', str(unknown_line)):
timeRange = time.strptime(str(unknown_line).split("=")[2].split()[0].split('.')[0],'%H:%M:%S')
timeRangeS = datetime.timedelta(hours=timeRange.tm_hour,minutes=timeRange.tm_min,seconds=timeRange.tm_sec).total_seconds()
- print(str(round(100*timeRangeS/totalRangeS, 1))+"% / 100%", end='\r')
+ print(str(round(100*timeRangeS/totalRangeS, 1))+"% / 100% "+str(exist), end='\r')
thread.close