Multi-threaded downloader that can retry a download on failure.

class Downloader[source]

Downloader(retries=3, thread_count=10, timeout=30)

Multi-threaded downloader that can retry a download on failure.

Downloader.add_callback[source]

Downloader.add_callback(callback)

Adds a callback that will be run after the download of the file.

:param callback: The callback to add.

Downloader.add_task[source]

Downloader.add_task(url, index)

Adds a task to the list of tasks to download.

Downloader.add_tasks[source]

Downloader.add_tasks(urls, indexes)

Adds a list of tasks to the list of tasks to download.

Downloader.download[source]

Downloader.download()

Downloads the files to the specified location.

Downloader.clear[source]

Downloader.clear()

Removes all of the downloads from the list of downloads.

Downloader.get_failed_downloads[source]

Downloader.get_failed_downloads()

Returns a list of downloads that failed to complete.

Callbacks

Callbacks to assign to the downloader

class SaveToDirectory[source]

SaveToDirectory(file_path)

Callback to download file to a specific directory.

SaveToDirectory.perform[source]

SaveToDirectory.perform(filename, data)

Saves the data to the specified file.

:param filename: The filename to write the file to. :param data: The data to save as a BytesIO object.