1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-30 23:24:16 +01:00

Merge pull request #512 from mutoso/master

Allow multiple URLs as arguments
This commit is contained in:
Johan Andersson 2017-01-20 15:50:12 +01:00 committed by GitHub
commit 4de8f8b451

View File

@ -152,6 +152,20 @@ class Options(object):
self.remux = False
self.silent_semi = False
def get_multiple_media(urls, options):
if options.output and os.path.isfile(options.output):
log.error("Output must be a directory if used with multiple URLs")
sys.exit(2)
elif options.output and not os.path.exists(options.output):
try:
os.makedirs(options.output)
except OSError as e:
log.error("%s: %s", e.strerror, e.filename)
return
for url in urls:
get_media(url, options)
def get_media(url, options):
if "http" not in url[:4]:
url = "http://%s" % url
@ -343,7 +357,7 @@ def setup_log(silent, verbose=False):
def main():
""" Main program """
usage = "Usage: %prog [options] url"
usage = "Usage: %prog [options] [urls]"
parser = OptionParser(usage=usage, version=__version__)
parser.add_option("-o", "--output",
metavar="OUTPUT", help="outputs to the given filename or folder")
@ -418,7 +432,7 @@ def main():
if not args:
parser.print_help()
sys.exit(0)
if len(args) != 1:
if len(args) < 1:
parser.error("Incorrect number of arguments")
if options.exclude:
options.exclude = options.exclude.split(",")
@ -438,10 +452,13 @@ def main():
log.error("flexible-quality requires a quality")
sys.exit(4)
url = args[0]
urls = args
try:
get_media(url, options)
if len(urls) == 1:
get_media(urls[0], options)
else:
get_multiple_media(urls, options)
except KeyboardInterrupt:
print("")