API
DownloadedFile
Represents a file downloaded from a URL.
Source code in pudly/pudly.py
__init__(path, total_size)
Initialise a DownloadedFile object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The path of the downloaded file. |
required |
total_size
|
int
|
The total size of the downloaded file from download information. |
required |
Source code in pudly/pudly.py
size_is_correct()
Compare the size of the file to the total size according to download information.
Returns:
| Type | Description |
|---|---|
bool
|
True if the size is correct, False otherwise. |
total_size_in_bytes()
Return the total size in bytes according to download information.
Returns:
| Type | Description |
|---|---|
int
|
The total size in bytes. |
FileToDownload
Represents a file to be downloaded from a URL.
Source code in pudly/pudly.py
__init__(response)
Initialise a FileToDownload object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
The response object from the requests to a URL. |
required |
Source code in pudly/pudly.py
download(download_chunk_size)
Download the file from the URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
download_chunk_size
|
int
|
The size of a fragment in bytes during download. |
required |
Returns:
| Type | Description |
|---|---|
DownloadedFile
|
The downloaded file object. |
Source code in pudly/pudly.py
download(url, query_parameters=None, download_dir=None, auth=None)
Download the file from the URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to download from. |
required |
query_parameters
|
dict | None
|
Parameters to pass to the URL. |
None
|
download_dir
|
Path | None
|
The directory to download the file to. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The path of the downloaded file. |
Raises:
| Type | Description |
|---|---|
DownloadError
|
If the download fails. |
Source code in pudly/pudly.py
download_files_concurrently(url_list, query_parameters=None, download_dir=None, auth=None, max_workers=5)
Download files from a list of URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url_list
|
list[str]
|
The list of URLs to download. |
required |
query_parameters
|
dict | None
|
The parameters to pass to the URLs. |
None
|
download_dir
|
Path | None
|
The directory to download the files to. |
None
|
max_workers
|
int
|
The maximum number of concurrent downloads. |
5
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
The list of paths to the downloaded files. |