pymovements.utils.downloads.download_file#

pymovements.utils.downloads.download_file(url: str, dirpath: Path, filename: str, md5: str | None = None, max_redirect_hops: int = 3, verbose: bool = True) Path#

Download a file from a URL and place it in root.

Parameters:
  • url (str) – URL of file to be downloaded.

  • dirpath (Path) – Path to directory where file will be saved to.

  • filename (str) – Target filename of saved file.

  • md5 (str | None) – MD5 checksum of downloaded file. If None, do not check. (default: None)

  • max_redirect_hops (int) – Maximum number of redirect hops allowed. (default: 3)

  • verbose (bool) – If True, show progress bar and print info messages on downloading file. (default: True)

Returns:

Filepath to downloaded file.

Return type:

Path

Raises:
  • OSError – If the download process failed.

  • RuntimeError – If the MD5 checksum of the downloaded file did not match the expected checksum.