From 62d8f4dc8d882ab20e2399059ddb5b65de81748a Mon Sep 17 00:00:00 2001 From: Ailothaen Date: Thu, 4 Mar 2021 19:47:58 +0100 Subject: [PATCH 1/2] Adding handling of several input files --- gallery_dl/__init__.py | 25 +++++++++++++------------ gallery_dl/option.py | 5 +++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index 6c2c71382b..c1f80b6e2d 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -196,7 +196,7 @@ def main(): cnt, "entry" if cnt == 1 else "entries", cache._path(), ) else: - if not args.urls and not args.inputfile: + if not args.urls and not args.inputfiles: parser.error( "The following arguments are required: URL\n" "Use 'gallery-dl --help' to get a list of all options.") @@ -208,18 +208,19 @@ def main(): jobtype = args.jobtype or job.DownloadJob urls = args.urls - if args.inputfile: - try: - if args.inputfile == "-": - if sys.stdin: - urls += parse_inputfile(sys.stdin, log) + if args.inputfiles: + for inputfile in args.inputfiles: + try: + if inputfile == "-": + if sys.stdin: + urls += parse_inputfile(sys.stdin, log) + else: + log.warning("input file: stdin is not readable") else: - log.warning("input file: stdin is not readable") - else: - with open(args.inputfile, encoding="utf-8") as file: - urls += parse_inputfile(file, log) - except OSError as exc: - log.warning("input file: %s", exc) + with open(inputfile, encoding="utf-8") as file: + urls += parse_inputfile(file, log) + except OSError as exc: + log.warning("input file: %s", exc) # unsupported file logging handler handler = output.setup_logging_handler( diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 60d911b957..7c5e7660a2 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -98,8 +98,9 @@ def build_parser(): ) general.add_argument( "-i", "--input-file", - dest="inputfile", metavar="FILE", - help="Download URLs found in FILE ('-' for stdin)", + dest="inputfiles", metavar="FILE", action="append", + help=("Download URLs found in FILE ('-' for stdin). " + "More than one --input-file can be specified"), ) general.add_argument( "--cookies", From 83587f048a5608918469697813bb605412f03bd4 Mon Sep 17 00:00:00 2001 From: Ailothaen Date: Thu, 4 Mar 2021 20:45:34 +0100 Subject: [PATCH 2/2] Fixed flake8 error due to bad indenting --- gallery_dl/option.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 7c5e7660a2..3e585fe02b 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -100,7 +100,7 @@ def build_parser(): "-i", "--input-file", dest="inputfiles", metavar="FILE", action="append", help=("Download URLs found in FILE ('-' for stdin). " - "More than one --input-file can be specified"), + "More than one --input-file can be specified"), ) general.add_argument( "--cookies",