A tool to download images from Reddit posts and comments and save them into a ZIP file.
Project description
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:
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:
pip install reddit-image-downloader
Configuration
Create a config.json file in the project root directory with the following structure:
{
"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.
Reddit-Image-Downloader/
│
├── reddit_image_downloader/
│ ├── __init__.py
│ ├── cli.py
│ ├── main.py
│ └── spinner.py
│
├── tests/
│ ├── __init__.py
│ └── test_main.py
│ └── package-test.py
│
├── .gitignore
├── LICENSE
├── MANIFEST.in
├── 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
Run the following command to start downloading images from a Reddit post:
reddit_image_downloader --help
You will be prompted to enter the Reddit post URL. The images will be saved to images.zip.
Python API
To use the functionality programmatically, import the module and call the download_images_from_post function:
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
python -m unittest discover -s tests
This will run all test cases defined in the tests directory.
Use cases
-
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.
-
Content Analysis: Researchers or analysts might need to collect images from Reddit for analyzing content trends or for training machine learning models.
-
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:
- Fork the repository.
- Create a new branch (git checkout -b feature/your-feature).
- Commit your changes (git commit -m 'Add new feature').
- Push to the branch (git push origin feature/your-feature).
- Open a pull request on GitHub.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
Project details
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
Hashes for reddit_image_downloader-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ced098b9dc345c56c10a1f6e17dba17cc9e6beae26b9a2fa1999bb55c3160661 |
|
MD5 | 4116cb64337e6f1795d4db0e813a5709 |
|
BLAKE2b-256 | f109355a30a876904a0905a5f1e83cdba1a8e51e5ab6f12f68483e46bcc8466f |
Hashes for reddit_image_downloader-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0aa1d44bdd94d68cb8f4ad31611d387ffa09f2af95c9c473e7341416f960edf2 |
|
MD5 | 595d78c0758c8b664b1b823db17ffa7a |
|
BLAKE2b-256 | e6d7b33a07e4407b58bb240069eb58612916adf49aaa86be69309aead2fb17c1 |