refined work of previous commit

This commit is contained in:
Kjistóf 2017-02-04 18:38:08 +01:00
parent 3974c5aa1c
commit a39bb01460

View File

@ -32,15 +32,15 @@ class File(Enum):
FRACTION = 3 FRACTION = 3
OUTPUT = 4 OUTPUT = 4
def call_verbose(before_message=''): def call_verbose(before_message='', after_message='Done!'):
def wrap(f): def tag(f):
@wraps(f) @wraps(f)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
print_opt(before_message+' ', end='', flush=True) print_opt(before_message, end='', flush=True)
f(*args, **kwargs) f(*args, **kwargs)
print_opt('Done!') print_opt(after_message)
return wrapper return wrapper
return wrap return tag
def print_opt(*args, **kwargs): def print_opt(*args, **kwargs):
if VERBOSE: if VERBOSE:
@ -59,7 +59,7 @@ def getDuration(ffprobe_output):
raise ValueError('Cannot process ffprobe output!') raise ValueError('Cannot process ffprobe output!')
return duration return duration
@call_verbose(before_message='Downloading audio stream...') @call_verbose(before_message='Downloading audio stream... ')
def download_audio_stream(): def download_audio_stream():
call(('youtube-dl', '--ignore-config', call(('youtube-dl', '--ignore-config',
'--extract-audio', '--extract-audio',
@ -67,7 +67,7 @@ def download_audio_stream():
URL), URL),
stdout=DEVNULL, stderr=DEVNULL) stdout=DEVNULL, stderr=DEVNULL)
@call_verbose(before_message='Downloading video stream...') @call_verbose(before_message='Downloading video stream... ')
def download_video_stream(): def download_video_stream():
call(('youtube-dl', '--ignore-config', call(('youtube-dl', '--ignore-config',
'--output', '{}.%(ext)s'.format(FILES[Stream.VIDEO]), '--output', '{}.%(ext)s'.format(FILES[Stream.VIDEO]),