Skip to main content

Robust MediaFire downloader with auto-resume, custom headers, retries, and bulk support.

Project description

mediafire-dl-cli

A robust MediaFire downloader with:

  • Auto-resume — interrupted downloads pick up where they left off via HTTP Range requests + .part files
  • Custom headers — pass any HTTP headers (cookies, auth, referer, …)
  • Retries + back-off — configurable retry count with exponential back-off on transient errors
  • Rich progress bar — speed (MB/s), ETA, percent, downloaded/total
  • Bulk/parallel download — thread-pool with configurable worker count
  • CLI — use straight from the terminal
  • Callback hookon_progress for GUI or logging integration

Install

pip install mediafire-dl-cli
# or for local development:
pip install -e .

Python API

Single file

from mediafire_dl_cli import Download

path = Download(
    url="https://www.mediafire.com/file/abc123/myarchive.zip",
    output="/home/user/downloads",   # optional, defaults to script dir
    filename="renamed.zip",          # optional
    headers={"Cookie": "session=xyz"},  # optional extra headers
    chunk_size=64 * 1024,            # 64 KB (default)
    retries=5,                       # HTTP-level retries (default 5)
    backoff=1.0,                     # exponential back-off factor
    show_progress=True,
    on_progress=lambda done, total: None,  # optional callback
)
print(f"Saved to {path}")

Auto-resume behaviour

If the download is interrupted (Ctrl-C, crash, network drop), a .part file is kept on disk.
Calling Download() again with the same arguments will automatically resume from the byte offset where it stopped — as long as the server supports Accept-Ranges.

If the server does not support range requests, a RangeNotSupportedError is raised.
Delete the .part file manually and start over in that case.


Bulk download

from mediafire_dl_cli import BulkDownload

urls = [
    "https://www.mediafire.com/file/abc/file1.zip",
    "https://www.mediafire.com/file/def/file2.zip",
    "https://www.mediafire.com/file/ghi/file3.zip",
]

results = BulkDownload(
    urls,
    output="/home/user/downloads",
    headers={"Referer": "https://example.com"},
    max_workers=3,   # parallel downloads
    retries=5,
    show_progress=True,
)

# results: {url: "/path/to/file" | Exception}
for url, result in results.items():
    if isinstance(result, Exception):
        print(f"FAILED  {url}: {result}")
    else:
        print(f"OK      {result}")

CLI Examples

Single file download

# Simple download to current directory
mediafire-dl-cli https://www.mediafire.com/file/abc123/video.mp4

# Download to specific directory with custom filename (filename inferred from URL if not provided)
mediafire-dl-cli https://www.mediafire.com/file/abc123/video.mp4 -o ~/Downloads

Bulk download (Parallel)

# Download multiple URLs using 5 parallel workers
mediafire-dl-cli url1 url2 url3 url4 url5 -w 5 -o ./my_collection

Advanced Usage

# Custom headers (useful for auth/sessions)
mediafire-dl-cli <url> -H "Cookie: session=abc" -H "User-Agent: MyDownloader/1.0"

# More retries for unstable connections (default is 5)
mediafire-dl-cli <url> -r 20

# Suppress progress bar (useful for cron jobs or logging)
mediafire-dl-cli <url> --no-progress

Exceptions

Exception When
ScraperError Download button not found / page unreachable
DownloadError HTTP or I/O error during transfer
RangeNotSupportedError Resume attempted but server rejects Range header

All inherit from MediaFireError for easy broad catching:

from mediafire_dl_cli.exceptions import MediaFireError
try:
    Download(url)
except MediaFireError as e:
    print(f"mediafire_dl_cli error: {e}")

Package layout

mediafire-dl-cli/
├── mediafire_dl_cli/
│   ├── __init__.py       exports: Download, BulkDownload, GetFileLink, …
│   ├── __main__.py       CLI entry point
│   ├── downloader.py     core download logic
│   ├── scraper.py        HTML scraping → direct link
│   ├── utils.py          helpers: AsMegabytes, GetFileSize, SupportsRanges
│   └── exceptions.py     custom exception hierarchy
├── pyproject.toml        modern packaging metadata
├── README.md             documentation
└── LICENSE               MIT license

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

mediafire_dl_cli-1.1.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

mediafire_dl_cli-1.1.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file mediafire_dl_cli-1.1.1.tar.gz.

File metadata

  • Download URL: mediafire_dl_cli-1.1.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mediafire_dl_cli-1.1.1.tar.gz
Algorithm Hash digest
SHA256 94b180029e80e79a17ebf985d3851a5d9c5035d410864f6014450bbccf2999cc
MD5 21b50963d798ea5e9aa2434b77d43535
BLAKE2b-256 f94b559d1da4c6c574dbf5221363d2dc1bd6eedd47ee9858609e99efd95f9e8c

See more details on using hashes here.

File details

Details for the file mediafire_dl_cli-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: mediafire_dl_cli-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mediafire_dl_cli-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 743535127f224d722ad7325279773bcbfe7e42b63e40148211cc553956283467
MD5 6b82b71370512da9b148c3a4468be260
BLAKE2b-256 a99e87fcae218ad8434a6a7dcd731b8d0d1962d556f4937d60c400c44197a9da

See more details on using hashes here.

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