From 20db3b68f71aed936f3dfc7a70051698b30e3189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Fri, 10 Feb 2017 20:11:08 +0100 Subject: [PATCH] finished refactor streak, fixed bug from last commit. closes #3. --- coub-dl.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/coub-dl.py b/coub-dl.py index 0553145..ab284d7 100644 --- a/coub-dl.py +++ b/coub-dl.py @@ -160,7 +160,8 @@ def check_for_ytdl_and_ffmpeg(): print_opt(error_str.format('youtube-dl')) elif not ffmpeg_found: print_opt(error_str.format('ffmpeg')) - exit() + + if not ytdl_found or not ffmpeg_found: exit() def determine_output_filename(url, user_supplied, extension, files_dict): @@ -171,6 +172,12 @@ def determine_output_filename(url, user_supplied, extension, files_dict): files_dict[File.OUTPUT] += extension +def build_default_files_dict(): + return {Stream.AUDIO: 'audio', Stream.VIDEO: 'video', + File.LIST: 'list.txt', File.LOOP: 'loop', File.FRACTION: 'fraction', + File.OUTPUT: ''}, [File.OUTPUT] + + def parse_cmd_arguments(): parser = ArgumentParser(description='Download player-looped videos with youtube-dl & ffmpeg.') parser.add_argument('-nv', '--nonverbose', action='store_true', help='Turn off non-critical messages to user') @@ -225,10 +232,7 @@ if __name__ == '__main__': check_for_ytdl_and_ffmpeg() # create dict that contains files used - FILES = {Stream.AUDIO: 'audio', Stream.VIDEO: 'video', - File.LIST: 'list.txt', File.LOOP: 'loop', File.FRACTION: 'fraction', - File.OUTPUT: 'output'+args.extension} - OUTPUT_KEYS = [File.OUTPUT] + FILES, OUTPUT_KEYS = build_default_files_dict() URL = args.url determine_output_filename(URL, args.output, args.extension, FILES)