Skip to main content

A simple batch downloader with chunked downloads

Project description

Batch Downloader

A simple Python package for downloading multiple files in parallel with chunked downloads.

Installation

pip install batch_downloader

Usage

def progress_callback(url: str, downloaded_size: int, total_size: int):
    if total_size > 0:
        progress = (downloaded_size / total_size) * 100
        print(f"Downloading {url}: {progress:.2f}%")
    else:
        print(f"Downloading {url}: {downloaded_size} bytes (total size unknown)")

downloader = BatchDownloader(
    urls=[
        "xxx",
        "xxx",
        ],
    output_dir="downloads",
    progress_callback=progress_callback,
)

results = downloader.download_all()

Async Usage

class TestAsyncBatchDownloader(unittest.TestCase):

    def progress_callback(self, url: str, downloaded_size: int, total_size: int):
        if total_size > 0:
            progress = (downloaded_size / total_size) * 100
            print(f"Downloading {url.split('/')[-1]}: {progress:.2f}% ({downloaded_size}/{total_size} bytes)")
        else:
            print(f"Downloading {url.split('/')[-1]}: {downloaded_size} bytes (total size unknown)")

    async def async_test_download(self):
        downloader = AsyncBatchDownloader(
            urls=[
                "xxx",
                "xxx",
            ],
            output_dir="downloads",
            progress_callback=self.progress_callback,
        )
        results = await downloader.download_all()
        self.assertTrue(isinstance(results, list))

    def test_download(self):
        asyncio.run(self.async_test_download())

if __name__ == "__main__":
    unittest.main()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

batch_downloader-0.1.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

batch_downloader-0.1.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file batch_downloader-0.1.2.tar.gz.

File metadata

  • Download URL: batch_downloader-0.1.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for batch_downloader-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b3b1badbbf17d30faf3bdd709313967fa35a45064d40a21033fa3282cc550f3a
MD5 bf2ac03d9ac0cae498c5e86cd32cab1e
BLAKE2b-256 b9187c24b376b54c5e0729a741efddbaccd1b21609fe7b80ef1db9a17033392c

See more details on using hashes here.

Provenance

The following attestation bundles were made for batch_downloader-0.1.2.tar.gz:

Publisher: python-publish.yml on Zzhenping/batch_downloader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file batch_downloader-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for batch_downloader-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3aa2d5b6ebe84421fea66dad7d305e5e4ac33213efcbf11b657c656c9921cb05
MD5 5625446de63dcc17d38cda5ad97d68f0
BLAKE2b-256 2c3ec21a90c86b827ea91d6720afaa8abb13bb2093d84c9731867dd9e0c31087

See more details on using hashes here.

Provenance

The following attestation bundles were made for batch_downloader-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on Zzhenping/batch_downloader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page