A simple http request file downloader.
Project description
Simple File Downloader
A lightweight Python utility for downloading files from the internet with:
- Automatic filename detection
- Extension-aware saving
- Generic filename fallback
- Duplicate filename prevention
This package provides a single, simple function:
download(url, output_dir)
Features
- Preserves file extensions correctly
- Generates a generic filename if none is detected
- Prevents filename duplication by auto-incrementing
- Minimal dependency design
- Easy to integrate into any project
📥 Installation
pip install getfiles
Or install locally:
git clone https://github.com/nattkorat/getfiles.git
cd getfiles
pip install .
Usage
from getfiles import downloader
url = "https://example.com/file.pdf"
output_dir = "./downloads"
downloader.download(url, output_dir)
How It Works
When downloading a file:
-
The package tries to extract the file extension from:
- The URL path
- The
Content(if available URL path failed)
-
Filename generation:
- A generic name using uuid4 is generated
This guarantees no overwriting and no duplicates.
Function Signature
download(url: str, output: str) -> str
Parameters
| Parameter | Type | Description |
|---|---|---|
url |
str | The URL of the file to download |
output |
str | Directory where the file will be saved |
Returns
str: Full path of the downloaded file
Design Philosophy
This package is intentionally simple:
- One function
- No complex configuration
- Safe file handling
- Production-friendly behavior
It is ideal for:
- Data collection scripts
- Web scraping pipelines
- Automation tools
- ML dataset downloading
- CLI utilities
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file getfiles-0.0.1.tar.gz.
File metadata
- Download URL: getfiles-0.0.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e916c478e5079f6ffabb0e8b50a0fb30e5056ee3c778d9c3fa772ebd18527869
|
|
| MD5 |
874f4a093bb0fba7ef6be113be1e4f85
|
|
| BLAKE2b-256 |
b7217b2fe37ba7cc1aecd4fe5e734c4ca3952d3a70c474027c7f5a7711ce4354
|
File details
Details for the file getfiles-0.0.1-py3-none-any.whl.
File metadata
- Download URL: getfiles-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
536bc30076321ee7ef210223488c53337af6c13ede34f04af8a460cfb16e85e0
|
|
| MD5 |
679daf4cd80d2763951a866e3cdee410
|
|
| BLAKE2b-256 |
6adc720d5b00e591791e2ea4b2409258e21dd408ec53e593fa7fe0cf923553d3
|