Metadata-Version: 2.4
Name: getfiles
Version: 0.0.1
Summary: A simple http request file downloader.
Author-email: Natt Korat <natt.korat@cadt.edu.kh>
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx
Requires-Dist: puremagic

# 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:

```python
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

```bash
pip install getfiles
```

Or install locally:

```bash
git clone https://github.com/nattkorat/getfiles.git
cd getfiles
pip install .
```

---

## Usage

```python
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:

1. The package tries to extract the file extension from:
   * The URL path
   * The `Content` (if available URL path failed)

2. Filename generation:
   * A generic name using uuid4 is generated

This guarantees **no overwriting** and **no duplicates**.

---

## Function Signature

```python
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

