Adding handling of several input files (#1353)
* Adding handling of several input files * Fixed flake8 error due to bad indenting
This commit is contained in:
parent
6e94491847
commit
2e8061091a
@ -196,7 +196,7 @@ def main():
|
|||||||
cnt, "entry" if cnt == 1 else "entries", cache._path(),
|
cnt, "entry" if cnt == 1 else "entries", cache._path(),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if not args.urls and not args.inputfile:
|
if not args.urls and not args.inputfiles:
|
||||||
parser.error(
|
parser.error(
|
||||||
"The following arguments are required: URL\n"
|
"The following arguments are required: URL\n"
|
||||||
"Use 'gallery-dl --help' to get a list of all options.")
|
"Use 'gallery-dl --help' to get a list of all options.")
|
||||||
@ -208,18 +208,19 @@ def main():
|
|||||||
jobtype = args.jobtype or job.DownloadJob
|
jobtype = args.jobtype or job.DownloadJob
|
||||||
|
|
||||||
urls = args.urls
|
urls = args.urls
|
||||||
if args.inputfile:
|
if args.inputfiles:
|
||||||
try:
|
for inputfile in args.inputfiles:
|
||||||
if args.inputfile == "-":
|
try:
|
||||||
if sys.stdin:
|
if inputfile == "-":
|
||||||
urls += parse_inputfile(sys.stdin, log)
|
if sys.stdin:
|
||||||
|
urls += parse_inputfile(sys.stdin, log)
|
||||||
|
else:
|
||||||
|
log.warning("input file: stdin is not readable")
|
||||||
else:
|
else:
|
||||||
log.warning("input file: stdin is not readable")
|
with open(inputfile, encoding="utf-8") as file:
|
||||||
else:
|
urls += parse_inputfile(file, log)
|
||||||
with open(args.inputfile, encoding="utf-8") as file:
|
except OSError as exc:
|
||||||
urls += parse_inputfile(file, log)
|
log.warning("input file: %s", exc)
|
||||||
except OSError as exc:
|
|
||||||
log.warning("input file: %s", exc)
|
|
||||||
|
|
||||||
# unsupported file logging handler
|
# unsupported file logging handler
|
||||||
handler = output.setup_logging_handler(
|
handler = output.setup_logging_handler(
|
||||||
|
@ -98,8 +98,9 @@ def build_parser():
|
|||||||
)
|
)
|
||||||
general.add_argument(
|
general.add_argument(
|
||||||
"-i", "--input-file",
|
"-i", "--input-file",
|
||||||
dest="inputfile", metavar="FILE",
|
dest="inputfiles", metavar="FILE", action="append",
|
||||||
help="Download URLs found in FILE ('-' for stdin)",
|
help=("Download URLs found in FILE ('-' for stdin). "
|
||||||
|
"More than one --input-file can be specified"),
|
||||||
)
|
)
|
||||||
general.add_argument(
|
general.add_argument(
|
||||||
"--cookies",
|
"--cookies",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user