File size: 1,220 Bytes
8247f19 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | diff --git a/mangadex_downloader/cli/validator.py b/mangadex_downloader/cli/validator.py
index dd3f636..deb4f81 100644
--- a/mangadex_downloader/cli/validator.py
+++ b/mangadex_downloader/cli/validator.py
@@ -31,15 +31,16 @@ def _validate(url):
raise argparse.ArgumentTypeError(str(e))
return _url
-def validate_url(url):
- if os.path.exists(url):
- with open(url, 'r') as opener:
- content = opener.read()
- else:
- content = url
+def _try_read(path):
+ if not os.path.exists(path):
+ return None
+
+ with open(path, 'r') as o:
+ return o.read()
+def validate_url(url):
urls = []
- for _url in content.splitlines():
+ for _url in url.splitlines():
if not _url:
continue
@@ -245,7 +246,8 @@ def validate(parser, args):
elif not os.path.exists(file_path):
parser.error(f"File \"{file_path}\" is not exist")
else:
- file_path = urls
+ file_content = _try_read(urls)
+ file_path = file_content if file_content is not None else urls
try:
args.URL = validate_url(file_path)
except argparse.ArgumentTypeError as e:
|