finished refactor streak, fixed bug from last commit. closes #3.

This commit is contained in:
Kjistóf 2017-02-10 20:11:08 +01:00
parent 5030c2f78c
commit 20db3b68f7

View File

@ -160,7 +160,8 @@ def check_for_ytdl_and_ffmpeg():
print_opt(error_str.format('youtube-dl')) print_opt(error_str.format('youtube-dl'))
elif not ffmpeg_found: elif not ffmpeg_found:
print_opt(error_str.format('ffmpeg')) 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): 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 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(): def parse_cmd_arguments():
parser = ArgumentParser(description='Download player-looped videos with youtube-dl & ffmpeg.') 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') 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() check_for_ytdl_and_ffmpeg()
# create dict that contains files used # create dict that contains files used
FILES = {Stream.AUDIO: 'audio', Stream.VIDEO: 'video', FILES, OUTPUT_KEYS = build_default_files_dict()
File.LIST: 'list.txt', File.LOOP: 'loop', File.FRACTION: 'fraction',
File.OUTPUT: 'output'+args.extension}
OUTPUT_KEYS = [File.OUTPUT]
URL = args.url URL = args.url
determine_output_filename(URL, args.output, args.extension, FILES) determine_output_filename(URL, args.output, args.extension, FILES)