espnet3.utils.download.download_url
Less than 1 minute
espnet3.utils.download.download_url
espnet3.utils.download.download_url(url: str, dst_path: Path, logger: Logger | None = None, step_percent: int = 5) → None
Download a URL to a local path with progress logging.
This uses urllib.request.urlretrieve and logs progress at fixed percentage intervals (default: every 5%). The destination directory is created if needed.
- Parameters:
- url (str) – The URL to download.
- dst_path (Path) – Destination file path.
- logger (logging.Logger | None) – Logger to emit progress messages. If None, messages are printed to stdout.
- step_percent (int) – Percentage step for progress logging.
- Returns: None
- Raises:
- URLError – If the download fails.
- HTTPError – If the server returns an error response.
Example
>>> from pathlib import Path
>>> download_url("https://example.com/file.tgz", Path("./data/file.tgz"))