Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 1.44 KB

README.md

File metadata and controls

44 lines (29 loc) · 1.44 KB

Multithreaded File Downloader

This Python script uses multithreading to download files from the web in parallel. It splits the file into multiple parts and downloads them concurrently, then merges them into a single file.

Dependencies

  • threading
  • concurrent.futures
  • requests

Usage

To use the script, simply replace the down_links variable with a list of URLs to download, and the File_name variable with a list of desired filenames for each download. Then run the script.

pythonCopy code

urls = down_links

with ThreadPoolExecutor(max_workers=10) as executor:
    futures = []
    for url, filename in zip(urls, File_name):
        futures.append(executor.submit(download, url, filename))

    for future in as_completed(futures):
        result = future.result()
        print(result)

How it works

The download() function takes in a URL and filename, then splits the file into 30 parts and downloads each part concurrently using threads. The download_part() function is called by the threads to download a specific part of the file.

Once all parts are downloaded, they are merged into a single file and the part files are deleted. The ThreadPoolExecutor is used to handle the threads and ensure that they are cleaned up correctly.

Contributions

Contributions and feedback are welcome! Please feel free to open an issue or submit a pull request.