diff options
author | neodarz <neodarz@neodarz.net> | 2017-07-12 14:53:04 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2017-07-12 14:53:04 +0200 |
commit | cb498521fcb38a9cca2d8b6d481e0063eeb1c91c (patch) | |
tree | 7e7edd00ced56d8e61bc99e52f7328ecc465512f /convert.py | |
parent | f2f86100de0b0b4201f6fd79e5dc06829ef20ef0 (diff) | |
download | video_save-cb498521fcb38a9cca2d8b6d481e0063eeb1c91c.tar.xz video_save-cb498521fcb38a9cca2d8b6d481e0063eeb1c91c.zip |
Add function to know if file exist
Diffstat (limited to '')
-rwxr-xr-x | convert.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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 |