Metadata-Version: 2.1
Name: reddit_image_downloader
Version: 0.1.2
Summary: A tool to download images from Reddit posts and comments and save them into a ZIP file.
Home-page: https://github.com/iamrishu11/Reddit-Image-Downloader
Author: Rishank Jain
Author-email: rishankj749@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: praw==7.7.1
Requires-Dist: requests==2.28.2
Requires-Dist: tqdm==4.65.0

# Reddit Image Downloader

A Python package for downloading images from Reddit posts and comments. This tool fetches images from a given Reddit post URL and stores them in a ZIP archive.

## Features

- Downloads images from Reddit comments.
- Handles images from both top-level comments and nested replies.
- Provides a progress spinner during the download process.
- Configurable via a `config.json` file.

## Installation

To install the package, clone the repository and use pip to install the dependencies:

```bash
git clone https://github.com/iamrishu11/Reddit-Image-Downloader.git
cd reddit-image-downloader
pip install -r requirements.txt
```

Alternatively, you can install the package directly from PyPI:

```bash
pip install reddit-image-downloader
```

## Configuration

Create a config.json file in the project root directory with the following structure:

```json
{
  "REDDIT_CLIENT_ID": "your_client_id",
  "REDDIT_SECRET": "your_client_secret",
  "REDDIT_USER_AGENT": "your_user_agent"
}
```
Replace the placeholders with your Reddit API credentials.

## Project directory

This is how your project directory should look like.

```plaintext
Reddit-Image-Downloader/
â”‚
â”œâ”€â”€ reddit_image_downloader/
â”‚   â”œâ”€â”€ __init__.py
â”‚   â”œâ”€â”€ cli.py
â”‚   â”œâ”€â”€ main.py
â”‚   â””â”€â”€ spinner.py
â”‚   
â”œâ”€â”€ tests/
â”‚   â”œâ”€â”€ __init__.py
â”‚   â””â”€â”€ package-test.py
â”‚   â””â”€â”€ test_main.py 
â”‚
â”œâ”€â”€ .gitignore
â”œâ”€â”€ LICENSE
â”œâ”€â”€ MANIFEST.in
â”œâ”€â”€ package.md
â”œâ”€â”€ README.md
â”œâ”€â”€ requirements.txt
â”œâ”€â”€ images.zip             # Created at Runtime
â”œâ”€â”€ setup.py
â””â”€â”€ config.json
```

## Usage

You can use the package either as a command-line tool or import it into your Python scripts.

### Command line tool

To get help and see the available options:
```bash
reddit_image_downloader --help 
```

To check the version of the installed package
```bash
reddit_image_downloader --version
```

To run the tool interactively and be prompted for a Reddit post URL and output ZIP file name:
```bash
reddit_image_downloader --run
```

To download images from a Reddit post directly by providing the post URL and the name of the output ZIP file:
```bash
reddit_image_downloader "https://www.reddit.com/r/example/comments/example_post/" "my_images.zip"
```

### Python API

To use the functionality programmatically, import the module and call the download_images_from_post function:

```python
from reddit_image_downloader.main import download_images_from_post

# Example usage
post_url = 'https://www.reddit.com/r/example/comments/example_post/'
output_zip = 'output_images.zip'
config = {
    'REDDIT_CLIENT_ID': 'your_client_id',
    'REDDIT_SECRET': 'your_client_secret',
    'REDDIT_USER_AGENT': 'your_user_agent'
}

download_images_from_post(post_url, output_zip, config)
```

## Testing

```bash
python -m unittest discover -s tests
```

This will run all test cases defined in the 'tests' directory.

## Use cases

1. **Archiving Reddit Media:** If you are archiving images from a particular Reddit post or thread for research or personal collection, this script automates the process, saving time and effort.

2. **Content Analysis:** Researchers or analysts might need to collect images from Reddit for analyzing content trends or for training machine learning models.

3. **Backup:** Users who want to back up images from interesting Reddit threads can use this script to download and store them conveniently.

## Contributing

Contributions are welcome! Please follow these steps to contribute:

1. Fork the repository.
2. Create a new branch (git checkout -b feature/your-feature).
3. Commit your changes (git commit -m 'Add new feature').
4. Push to the branch (git push origin feature/your-feature).
5. Open a pull request on GitHub.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgements

- [PRAW](https://pypi.org/project/praw/) for interacting with the Reddit API.
- [Requests](https://pypi.org/project/requests/) for handling HTTP requests.
- [TQDM](https://pypi.org/project/tqdm/) for the progress bar
