
# Weibo Image Rescue Tool

## Introduction

The Weibo Image Rescue Tool is a command-line utility designed to help you rescue images from Weibo by updating and using CDN information.

Inspired by [t0mbkeeper](https://weibo.com/6827625527/Ong3JyBf4) and [weibo-image-hound](https://github.com/zry98/weibo-image-hound/tree/main).

80% of the code was generated by ChatGPT-4.

## Features

- Update CDN information
- Force update CDN information and rescue image from a specific URL
- Rescue image from a specified URL

## Installation

Install from PyPI:

```bash
pip install weibo-image-rescue-tool
```

For local development:

```bash
git clone https://github.com/rquanx/weibo-image-rescue.git
cd weibo-image-rescue
pip install -e .
```

## Usage

### Update CDN Information

To update CDN information, use the `-u` flag:

```bash
weibo-image-rescue -u
```

### Force Update CDN Information and Rescue Image

To force update CDN information and rescue an image from a specific URL, use one of:

Preferred:

```bash
weibo-image-rescue --force-update <image_url>
```

Backward-compatible:

```bash
weibo-image-rescue -f <image_url>
```

### Rescue Image from a Specified URL

To rescue an image from a specified URL without updating the CDN information, simply provide the image URL:

```bash
weibo-image-rescue <image_url>
```

### Rescue Image with different quality

```bash
weibo-image-rescue <image_url> # default quality is all
weibo-image-rescue <image_url> -q ol,l,ml,m,o,t # form large to small
```

### Tune Concurrency and Timeout

```bash
weibo-image-rescue <image_url> --workers 30 --timeout 8
```

### Output Directory

```bash
weibo-image-rescue <image_url> --output-dir ./images
```

### Example

```bash
weibo-image-rescue -f https://example.com/image.jpg
```

## Arguments

- `-u, --update-cdn` : Update CDN information only.
- `--force-update` : Force update CDN information before rescuing positional `image_url`.
- `-f <image_url>` : Backward-compatible mode, force update and rescue specified URL.
- `-q` : Quality list, comma-separated values, e.g. `ol,l,ml,m,o,t`.
- `--workers` : Max concurrent probing requests.
- `--timeout` : Per-request timeout in seconds.
- `-o, --output-dir` : Directory for rescued image files.
- `image_url` : The URL of the image to rescue.

## License

This project is licensed under the terms of the GNU General Public License v3.0. See [LICENSE](LICENSE) for more details.

## Acknowledgements

Special thanks to all contributors and the open-source community for their invaluable support and contributions.
