summaryrefslogtreecommitdiff
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
commitcb498521fcb38a9cca2d8b6d481e0063eeb1c91c (patch)
tree7e7edd00ced56d8e61bc99e52f7328ecc465512f
parentf2f86100de0b0b4201f6fd79e5dc06829ef20ef0 (diff)
downloadvideo_save-cb498521fcb38a9cca2d8b6d481e0063eeb1c91c.tar.xz
video_save-cb498521fcb38a9cca2d8b6d481e0063eeb1c91c.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