diff options
Diffstat (limited to 'gallery_dl/__init__.py')
| -rw-r--r-- | gallery_dl/__init__.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index 6fba5e2..e71a5b0 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -108,7 +108,7 @@ def parse_inputfile(file, log): def main(): try: - if sys.stdout.encoding.lower() != "utf-8": + if sys.stdout and sys.stdout.encoding.lower() != "utf-8": output.replace_std_streams() parser = option.build_parser() @@ -205,11 +205,13 @@ def main(): if args.inputfile: try: if args.inputfile == "-": - file = sys.stdin + if sys.stdin: + urls += parse_inputfile(sys.stdin, log) + else: + log.warning("input file: stdin is not readable") else: - file = open(args.inputfile, encoding="utf-8") - urls += parse_inputfile(file, log) - file.close() + with open(args.inputfile, encoding="utf-8") as file: + urls += parse_inputfile(file, log) except OSError as exc: log.warning("input file: %s", exc) |
