added option to override output file name

This commit is contained in:
Kjistóf 2017-02-04 14:40:10 +01:00
parent dc03475d49
commit 59b089726e
1 changed files with 7 additions and 2 deletions

View File

@ -12,6 +12,7 @@ from argparse import ArgumentParser
# parse arguments
parser = ArgumentParser(description='Download player-looped videos with youtube-dl & ffmpeg.')
parser.add_argument('-nv', '--nonverbose', help='Turn off non-critical messages to user.')
parser.add_argument('-o', '--output', default=None, help='Specify name of the output file (use -e for extension).')
parser.add_argument('-e', '--extension', default='mp4', help='Set the container to use for the output.')
parser.add_argument('url', type=str, help='The URL of the site containing the video to download.')
@ -96,8 +97,12 @@ OUTPUT_KEYS = [File.OUTPUT]
URL = args.url
# fetch video title
FILES[File.OUTPUT] = check_output(('youtube-dl', '--get-title', args.url)).decode('utf-8').strip() + args.extension
# fetch video title if no filename was specified
if args.output is None:
FILES[File.OUTPUT] = check_output(('youtube-dl', '--get-title', args.url)).decode('utf-8').strip()
else:
FILES[File.OUTPUT] = args.output
FILES[File.OUTPUT] += args.extension
# ask what to do if output exists
if exists(FILES[File.OUTPUT]):