{"library":"parfive","title":"Parfive: Parallel File Downloader","description":"Parfive is an asynchronous HTTP and FTP parallel file downloader for Python. It leverages `asyncio` to efficiently download multiple files concurrently, providing features like progress bars, connection throttling, and retry mechanisms. The current version, 2.3.1, offers a robust asynchronous API for managing large-scale file transfers. Releases are made periodically to add features, address issues, and ensure compatibility with newer Python versions, maintaining an active development status.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install parfive"],"cli":{"name":"parfive","version":"parfive 2.3.1"}},"imports":["from parfive import Downloader"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import parfive\nimport asyncio\nimport os\n\nasync def main():\n    # Define some public URLs to download\n    urls = [\n        \"https://raw.githubusercontent.com/sunpy/parfive/main/README.md\",\n        \"https://raw.githubusercontent.com/sunpy/parfive/main/LICENSE\"\n    ]\n\n    # Create a directory for downloads if it doesn't exist\n    download_dir = \"parfive_downloads\"\n    os.makedirs(download_dir, exist_ok=True)\n\n    # Initialize the Downloader with a maximum of 5 concurrent connections\n    # and display a progress bar.\n    downloader = parfive.Downloader(max_conn=5, progress=True)\n\n    # Add URLs to the downloader, specifying the local path\n    for url in urls:\n        downloader.add_url(url, path=download_dir)\n\n    # Execute the downloads asynchronously\n    print(f\"Starting download of {len(urls)} files to '{download_dir}'...\")\n    results = await downloader.download()\n\n    # Print the paths of the downloaded files\n    print(\"Downloaded files:\")\n    for filepath in results:\n        print(f\"- {filepath}\")\n\n    # Optionally clean up the downloaded files\n    # for filepath in results:\n    #     os.remove(filepath)\n    # os.rmdir(download_dir)\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","lang":"python","description":"This example demonstrates how to use `parfive.Downloader` to download multiple public files concurrently to a local directory. It shows how to initialize the downloader, add URLs, and await the results. The `asyncio.run()` function is used to execute the asynchronous main function.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}