refactored some method names
This commit is contained in:
parent
e4283ee3b7
commit
424a6e156a
12
coub-dl.py
12
coub-dl.py
@ -38,13 +38,13 @@ def print_opt(*args, **kwargs):
|
||||
print(*args, **kwargs)
|
||||
|
||||
|
||||
def getCmdStdErr(command):
|
||||
def get_command_stderr(command):
|
||||
process = Popen(command, stderr=PIPE, stdout=PIPE)
|
||||
out, err = process.communicate()
|
||||
return err
|
||||
|
||||
|
||||
def getDuration(ffprobe_output):
|
||||
def get_duration(ffprobe_output):
|
||||
durationPattern = r'.*Duration:\s(.+),\sstart.*'
|
||||
regex = match(durationPattern, str(ffprobe_output))
|
||||
duration = regex.groups()[0] if regex else None
|
||||
@ -70,7 +70,7 @@ def download_video_stream():
|
||||
stdout=DEVNULL, stderr=DEVNULL)
|
||||
|
||||
|
||||
def readExtensions():
|
||||
def read_extensions():
|
||||
for file in listdir():
|
||||
for filename in FILES:
|
||||
if match('^{}.*'.format(FILES[filename]), file):
|
||||
@ -171,11 +171,11 @@ if exists(FILES[File.OUTPUT]):
|
||||
# download streams and update FILE dict with extensions
|
||||
download_audio_stream()
|
||||
download_video_stream()
|
||||
readExtensions()
|
||||
read_extensions()
|
||||
|
||||
# get stream lengths via ffprobe
|
||||
audioData= getDuration(getCmdStdErr(('ffprobe', FILES[Stream.AUDIO]))).split(':')
|
||||
videoData = getDuration(getCmdStdErr(('ffprobe', FILES[Stream.VIDEO]))).split(':')
|
||||
audioData= get_duration(get_command_stderr(('ffprobe', FILES[Stream.AUDIO]))).split(':')
|
||||
videoData = get_duration(get_command_stderr(('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]))
|
||||
|
Loading…
Reference in New Issue
Block a user