aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconvert.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/convert.py b/convert.py
index 0a7c034..9f3ac2e 100755
--- a/convert.py
+++ b/convert.py
@@ -75,17 +75,17 @@ for file in sorted(os.listdir(sourcedir)):
thread.close
elif i == 2:
unknown_line = thread.match.group(0)
- if re.match(r'.*Duration.*', str(unknown_line)):
- count = 0
- for element in unknown_line.split():
- count += 1
- if re.match(r"^b'Duration:'$", str(element)):
- break
- total = str(unknown_line.split()[count]).split("'")[1].split(',')[0]
+ ffmpeg_time = re.search('(Duration: [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9])', str(unknown_line), re.IGNORECASE)
+
+ if ffmpeg_time:
+ total = str(ffmpeg_time[0]).split(' ')[1]
totalRange = time.strptime(total.split('.')[0],'%H:%M:%S')
totalRangeS = datetime.timedelta(hours=totalRange.tm_hour,minutes=totalRange.tm_min,seconds=totalRange.tm_sec).total_seconds()
- if re.match(r'.*time=.*', str(unknown_line)):
- timeRange = time.strptime(str(unknown_line).partition("time=")[2].split('.')[0],'%H:%M:%S')
+
+ ffmpeg_time = re.search('(time=[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9])', str(unknown_line), re.IGNORECASE)
+
+ if ffmpeg_time:
+ timeRange = time.strptime(str(ffmpeg_time[0]).split('.')[0].split('=')[1],'%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% "+str(exist), end='\r')