mirror of
https://github.com/kemayo/leech
synced 2025-12-06 16:33:16 +01:00
Allow passing in multiple URLs
Good trick: `./leech.py examples/practical{1,2,3,4,5,6,7}.json`
This commit is contained in:
parent
c3b28d6169
commit
b8314341b2
1 changed files with 15 additions and 11 deletions
12
leech.py
12
leech.py
|
|
@ -142,7 +142,7 @@ def flush(verbose):
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.argument('url')
|
@click.argument('urls', nargs=-1, required=True)
|
||||||
@click.option(
|
@click.option(
|
||||||
'--site-options',
|
'--site-options',
|
||||||
default='{}',
|
default='{}',
|
||||||
|
|
@ -157,17 +157,21 @@ def flush(verbose):
|
||||||
@click.option('--normalize/--no-normalize', default=True, help="Whether to normalize strange unicode text")
|
@click.option('--normalize/--no-normalize', default=True, help="Whether to normalize strange unicode text")
|
||||||
@click.option('--verbose', '-v', is_flag=True, help="Verbose debugging output")
|
@click.option('--verbose', '-v', is_flag=True, help="Verbose debugging output")
|
||||||
@site_specific_options # Includes other click.options specific to sites
|
@site_specific_options # Includes other click.options specific to sites
|
||||||
def download(url, site_options, cache, verbose, normalize, output_dir, **other_flags):
|
def download(urls, site_options, cache, verbose, normalize, output_dir, **other_flags):
|
||||||
"""Downloads a story and saves it on disk as a ebpub ebook."""
|
"""Downloads a story and saves it on disk as a ebpub ebook."""
|
||||||
configure_logging(verbose)
|
configure_logging(verbose)
|
||||||
session = create_session(cache)
|
session = create_session(cache)
|
||||||
|
|
||||||
|
for url in urls:
|
||||||
site, url = sites.get(url)
|
site, url = sites.get(url)
|
||||||
options, login = create_options(site, site_options, other_flags)
|
options, login = create_options(site, site_options, other_flags)
|
||||||
output_dir = output_dir or options.get('output_dir', os.getcwd())
|
|
||||||
story = open_story(site, url, session, login, options)
|
story = open_story(site, url, session, login, options)
|
||||||
if story:
|
if story:
|
||||||
filename = ebook.generate_epub(story, options, normalize=normalize, output_dir=output_dir)
|
filename = ebook.generate_epub(
|
||||||
|
story, options,
|
||||||
|
normalize=normalize,
|
||||||
|
output_dir=output_dir or options.get('output_dir', os.getcwd())
|
||||||
|
)
|
||||||
logger.info("File created: " + filename)
|
logger.info("File created: " + filename)
|
||||||
else:
|
else:
|
||||||
logger.warning("No ebook created")
|
logger.warning("No ebook created")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue