multiurl

0.3.7 · active · verified Mon Apr 13

multiurl is a Python package designed to simplify downloading multiple URLs, including support for multi-part URLs. It allows downloading several files into one or specific byte ranges from a single URL. Maintained by ECMWF, it has seen regular updates, with version 0.3.7 released in July 2025, indicating an active development cadence despite its listed 'Alpha' status on PyPI.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the `multiurl.download` function. It supports downloading single URLs, combining multiple URLs into one target file, and fetching specific byte-range 'parts' from a single URL. The provided code simulates network operations to ensure it is runnable without external network dependencies for demonstration purposes.

from multiurl import download
import os

# NOTE: For this quickstart, actual network requests are simulated for illustrative
# purposes to ensure it is runnable without external dependencies or network issues.
# In a real application, 'download' performs actual HTTP/FTP requests.

def simulated_download(url, target=None, parts=None, **kwargs):
    print(f"\n--- Simulating download operation ---")
    print(f"  URLs(s): {url}")
    print(f"  Target file: {target}")
    if parts:
        print(f"  Requested parts: {parts}")
    print(f"  Additional parameters: {kwargs}")
    if target:
        try:
            with open(target, 'w') as f:
                f.write(f"Simulated content for {target} from {url}\n")
            print(f"  Created simulated file: {target}")
        except IOError as e:
            print(f"  Error creating simulated file {target}: {e}")
    print("--- Simulation complete ---")

# Monkey-patch the actual download function for simulation in quickstart
# In a real application, you would just call `multiurl.download`
multiurl.download = simulated_download

# Example 1: Download a single URL into a specified target file
multiurl.download(url="http://example.com/data.txt", target="example_data.txt")

# Example 2: Download content from multiple URLs and combine into one file
multiurl.download(
    url=["http://example.com/part1.json", "http://example.com/part2.json"],
    target="combined_parts.json"
)

# Example 3: Download specific byte ranges (parts) from a single URL
# This requires the server to support HTTP Range requests.
multiurl.download(
    url="http://example.com/large_file.bin",
    parts=[(0, 1024), (2048, 512)],
    target="file_segments.bin"
)

# Clean up simulated files (optional, for actual cleanup uncomment below)
# os.remove("example_data.txt")
# os.remove("combined_parts.json")
# os.remove("file_segments.bin")

print("\nQuickstart demonstration complete. Check your directory for simulated files.")

view raw JSON →