From 424a6e156aed2d3c5f3bfa2c796e06b04c0e6bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 4 Feb 2017 23:15:33 +0100 Subject: [PATCH] refactored some method names --- coub-dl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/coub-dl.py b/coub-dl.py index 1ce16c4..26c18f7 100644 --- a/coub-dl.py +++ b/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]))