feat(dl): Add *new* --workers to set download threads/workers
The previously named --workers which is now --downloads specified how many tracks to download, not how many threads/workers are used per-download. It defaults to nothing, which each downloader then has their own defaults. All current downloaders though currently default to `min(32, (os.cpu_count() or 1) + 4)`, which is also the default for `ThreadPoolExecutor` in general. This also brings a side effect of changing DASH and HLS's forced max_workers of 16 to now a more appropriate default but more importantly actually configurable. You can set a default in your config under `dl.workers`.
This commit is contained in:
@@ -135,6 +135,7 @@ class Track:
|
||||
self,
|
||||
session: Session,
|
||||
prepare_drm: partial,
|
||||
max_workers: Optional[int] = None,
|
||||
progress: Optional[partial] = None
|
||||
):
|
||||
"""Download and optionally Decrypt this Track."""
|
||||
@@ -191,6 +192,7 @@ class Track:
|
||||
progress=progress,
|
||||
session=session,
|
||||
proxy=proxy,
|
||||
max_workers=max_workers,
|
||||
license_widevine=prepare_drm
|
||||
)
|
||||
elif self.descriptor == self.Descriptor.DASH:
|
||||
@@ -201,6 +203,7 @@ class Track:
|
||||
progress=progress,
|
||||
session=session,
|
||||
proxy=proxy,
|
||||
max_workers=max_workers,
|
||||
license_widevine=prepare_drm
|
||||
)
|
||||
elif self.descriptor == self.Descriptor.URL:
|
||||
@@ -236,7 +239,8 @@ class Track:
|
||||
filename=save_path.name,
|
||||
headers=session.headers,
|
||||
cookies=session.cookies,
|
||||
proxy=proxy
|
||||
proxy=proxy,
|
||||
max_workers=max_workers
|
||||
):
|
||||
file_downloaded = status_update.get("file_downloaded")
|
||||
if not file_downloaded:
|
||||
|
||||
Reference in New Issue
Block a user