refactor(dl): Change --workers to --downloads

This commit is contained in:
rlaphoenix 2024-04-02 23:34:45 +01:00
parent fb5580882b
commit 0cf20f84a9

View File

@ -131,8 +131,8 @@ class dl:
help="Disable folder creation for TV Shows.") help="Disable folder creation for TV Shows.")
@click.option("--no-source", is_flag=True, default=False, @click.option("--no-source", is_flag=True, default=False,
help="Disable the source tag from the output file name and path.") help="Disable the source tag from the output file name and path.")
@click.option("--workers", type=int, default=1, @click.option("--downloads", type=int, default=1,
help="Max concurrent workers to use throughout the code, particularly downloads.") help="Amount of tracks to download concurrently.")
@click.pass_context @click.pass_context
def cli(ctx: click.Context, **kwargs: Any) -> dl: def cli(ctx: click.Context, **kwargs: Any) -> dl:
return dl(ctx, **kwargs) return dl(ctx, **kwargs)
@ -275,7 +275,7 @@ class dl:
no_proxy: bool, no_proxy: bool,
no_folder: bool, no_folder: bool,
no_source: bool, no_source: bool,
workers: int, downloads: int,
*_: Any, *_: Any,
**__: Any **__: Any
) -> None: ) -> None:
@ -502,7 +502,7 @@ class dl:
console=console, console=console,
refresh_per_second=5 refresh_per_second=5
): ):
with ThreadPoolExecutor(workers) as pool: with ThreadPoolExecutor(downloads) as pool:
for download in futures.as_completed(( for download in futures.as_completed((
pool.submit( pool.submit(
track.download, track.download,
@ -542,7 +542,7 @@ class dl:
except Exception as e: # noqa except Exception as e: # noqa
error_messages = [ error_messages = [
":x: Download Failed...", ":x: Download Failed...",
" One of the download workers had an error!", " One of the track downloads had an error!",
" See the error trace above for more information." " See the error trace above for more information."
] ]
if isinstance(e, subprocess.CalledProcessError): if isinstance(e, subprocess.CalledProcessError):