mirror of
https://github.com/jo1gi/grawlix.git
synced 2026-06-06 06:24:58 -06:00
Add file argument to read urls from file
This commit is contained in:
parent
0d7fdd04a0
commit
03e67a6515
@ -29,6 +29,22 @@ def get_login(source: Source, config: Config, options) -> Tuple[str, str]:
|
|||||||
return username, password
|
return username, password
|
||||||
|
|
||||||
|
|
||||||
|
def get_urls(options) -> list[str]:
|
||||||
|
"""
|
||||||
|
Retrieves all available urls from input arguments
|
||||||
|
- From urls argument
|
||||||
|
- From file argument
|
||||||
|
"""
|
||||||
|
urls = []
|
||||||
|
if options.urls:
|
||||||
|
urls.extend(options.urls)
|
||||||
|
if options.file:
|
||||||
|
with open(options.file, "r") as f:
|
||||||
|
content = f.read()
|
||||||
|
urls.extend(content.split("\n"))
|
||||||
|
return urls
|
||||||
|
|
||||||
|
|
||||||
def authenticate(source: Source, config: Config, options):
|
def authenticate(source: Source, config: Config, options):
|
||||||
"""
|
"""
|
||||||
Authenticate with source
|
Authenticate with source
|
||||||
@ -47,7 +63,8 @@ def authenticate(source: Source, config: Config, options):
|
|||||||
def main() -> None:
|
def main() -> None:
|
||||||
args = arguments.parse_arguments()
|
args = arguments.parse_arguments()
|
||||||
config = load_config()
|
config = load_config()
|
||||||
for url in args.urls:
|
urls = get_urls(args)
|
||||||
|
for url in urls:
|
||||||
source: Source = find_source(url)
|
source: Source = find_source(url)
|
||||||
if source.requires_authentication:
|
if source.requires_authentication:
|
||||||
authenticate(source, config, args)
|
authenticate(source, config, args)
|
||||||
|
|||||||
@ -20,6 +20,12 @@ def parse_arguments():
|
|||||||
help = "Links to ebooks",
|
help = "Links to ebooks",
|
||||||
nargs = "*"
|
nargs = "*"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-f',
|
||||||
|
'--file',
|
||||||
|
help = "File with links (One link per line)",
|
||||||
|
dest = "file"
|
||||||
|
)
|
||||||
# Authentication
|
# Authentication
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-u',
|
'-u',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user