implemented calculation of looping
This commit is contained in:
parent
3889b760c3
commit
a62ca9d50c
19
coub-dl.py
19
coub-dl.py
@ -3,6 +3,8 @@ from os import listdir
|
||||
from re import match
|
||||
from sys import argv
|
||||
from enum import Enum
|
||||
from datetime import timedelta
|
||||
from math import ceil
|
||||
|
||||
|
||||
|
||||
@ -41,8 +43,21 @@ for file in listdir():
|
||||
if match('^{}.*'.format(FILES[filename]), file):
|
||||
FILES[filename] = file
|
||||
|
||||
audioLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', FILES[Stream.AUDIO])))
|
||||
videoLen = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', FILES[Stream.VIDEO])))
|
||||
audioData= getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', FILES[Stream.AUDIO]))).split(':')
|
||||
videoData = getDuration(getCmdStdErr(('/usr/bin/env', 'ffprobe', FILES[Stream.VIDEO]))).split(':')
|
||||
|
||||
audioLen = timedelta(hours=float(audioData[0]), minutes=float(audioData[1]), seconds=float(audioData[2]))
|
||||
videoLen = timedelta(hours=float(videoData[0]), minutes=float(videoData[1]), seconds=float(videoData[2]))
|
||||
|
||||
print(audioLen)
|
||||
print(videoLen)
|
||||
|
||||
longer = audioLen if audioLen > videoLen else videoLen
|
||||
shorter = audioLen if audioLen < videoLen else videoLen
|
||||
|
||||
timesLoop = ceil(longer.seconds / shorter.seconds)
|
||||
|
||||
print('Longer: {}'.format(longer))
|
||||
print('Shorter: {}'.format(shorter))
|
||||
|
||||
print('Loop {} times.'.format(timesLoop))
|
||||
|
Loading…
Reference in New Issue
Block a user