Metadata-Version: 2.4
Name: ua-card-image-grep
Version: 0.1.2
Summary: Download Union Arena card images from rugiacreation.com search pages with getUAcard(serial_name, url)
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: beautifulsoup4<5,>=4.12
Requires-Dist: requests<3,>=2.31
Dynamic: license-file

# ua-card-image-grep

Download UNION ARENA card images from [rugiacreation.com](https://rugiacreation.com/ua/) search result pages.

## Installation

```bash
pip install ua-card-image-grep
```

Requires Python 3.14+.

## Usage

```python
from ua_card_image_grep import getUAcard

paths = getUAcard(
    "明日方舟-藍",
    "https://rugiacreation.com/ua/search?Name=HK&Version=ARK&Color1=%E8%97%8D",
)
```

The images are saved to `cards/明日方舟-藍/`, and the function returns a list of the image paths.

### `getUAcard(serial_name, url, output="cards", *, delay=0.8, timeout=30, overwrite=False, html=None)`

| Parameter | Description |
|---|---|
| `serial_name` | Name of the folder that stores the downloaded images (created under `output`). |
| `url` | Search result page to scrape. |
| `output` | Base output directory. Default `cards`. |
| `delay` | Seconds to wait between image downloads. Default `0.8`. |
| `timeout` | HTTP timeout in seconds. Default `30`. |
| `overwrite` | Re-download images that already exist. Default `False` (existing files are skipped). |
| `html` | Parse this saved HTML instead of fetching `url`. |

Raises `RuntimeError` if no cards are found at the page.

### File names

Images are named `{card id}_{rarity}.{ext}`, for example:

```text
UA43BT_SMD-1-042_C.jpg
UA43BT_SMD-1-046_2_SR★★.jpg
```

Alternate-art cards have `_2` (or `_3`) in the card id, so they never overwrite the normal card.

### Preset URLs

`url_map` holds search URLs for some sets:

```python
from ua_card_image_grep import getUAcard, url_map

getUAcard("破曉傳說-藍", url_map["破曉傳說-藍"])
```

## Command line

```bash
python -m ua_card_image_grep 明日方舟-藍 "https://rugiacreation.com/ua/search?Name=HK&Version=ARK&Color1=%E8%97%8D" -o ./cards
```

If the URL is omitted and `serial_name` is a key of `url_map`, the preset URL is used. Other options: `--delay`, `--timeout`, `--overwrite`.

## License

See [LICENSE](LICENSE).
