diff --git a/coub-dl.py b/coub-dl.py index d98d894..2126941 100644 --- a/coub-dl.py +++ b/coub-dl.py @@ -16,6 +16,7 @@ from functools import wraps from tempfile import mkdtemp from shutil import rmtree from signal import signal, SIGINT +from sys import exit @@ -145,30 +146,17 @@ def mux_streams(file_dict): stdout=DEVNULL, stderr=DEVNULL) -@call_verbose(before_message='Checking your system for youtube-dl and ffmpeg... ', after_message='Found both!') -def check_for_ytdl_and_ffmpeg(): - error_str = '\nNo {} found in PATH! coub-dl requires youtube-dl & ffmpeg.' - ytdl_found = False - ffmpeg_found = False - try: - check_output(('youtube-dl', '--version')) - ytdl_found = True - except (CalledProcessError, FileNotFoundError): - pass - try: - check_output(('ffmpeg', '-version')) - ffmpeg_found = True - except (CalledProcessError, FileNotFoundError): - pass +@call_verbose(before_message='Checking your system for dependencies... ', after_message='Found all!') +def check_for_dependencies(): + check_for = (('youtube-dl', '--version'), ('ffmpeg', '-version'), ('curl', '--version')) + error_str = '\nMissing dependencies: {}' + missing = [] - if not ytdl_found and not ffmpeg_found: - print_opt(error_str.format('youtube-dl nor ffmpeg')) - elif not ytdl_found: - print_opt(error_str.format('youtube-dl')) - elif not ffmpeg_found: - print_opt(error_str.format('ffmpeg')) + for command in check_for: + try: check_output(command) + except (CalledProcessError, FileNotFoundError): missing.append(command[0]) - if not ytdl_found or not ffmpeg_found: exit() + if missing: exit(error_str.format(', '.join(missing))) def determine_output_filename(url, user_supplied, extension, files_dict): @@ -243,7 +231,7 @@ if __name__ == '__main__': args = parse_cmd_arguments() VERBOSE = False if args.nonverbose else True - check_for_ytdl_and_ffmpeg() + check_for_dependencies() # create dict that contains files used FILES, OUTPUT_KEYS = build_default_files_dict()