# 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
The package comes with a pre-configured config.json file that is included in the distribution. This file contains default Reddit API credentials which are used when the package is executed. To use these default credentials, you don’t need to create a separate config.json.
If you need to use different credentials or override the default configuration, you can create your own config.json in the same directory where the script is executed, with the following structure: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.
Note: Although this package includes default API credentials, it's a good practice to provide your own configuration file for personal use to avoid exposing the default credentials
## 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 check information about author and code
```bash
reddit_image_downloader --author
```
- 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.
## 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
Raw data
{
"_id": null,
"home_page": "https://github.com/iamrishu11/Reddit-Image-Downloader",
"name": "reddit-image-downloader",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Rishank Jain",
"author_email": "rishankj749@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f5/21/102831a0dcaeef26d4823d60fbcd20cade932f92e1fe1526edf2da7cde42/reddit_image_downloader-0.1.5.tar.gz",
"platform": null,
"description": "# Reddit Image Downloader\r\nA 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.\r\n\r\n## Features\r\n\r\n- Downloads images from Reddit comments.\r\n- Handles images from both top-level comments and nested replies.\r\n- Provides a progress spinner during the download process.\r\n- Configurable via a `config.json` file.\r\n\r\n## Installation\r\n\r\nTo install the package, clone the repository and use pip to install the dependencies:\r\n```bash\r\ngit clone https://github.com/iamrishu11/Reddit-Image-Downloader.git\r\ncd reddit-image-downloader\r\npip install -r requirements.txt\r\n```\r\n\r\nAlternatively, you can install the package directly from PyPI:\r\n```bash\r\npip install reddit-image-downloader\r\n```\r\n\r\n## Configuration\r\n\r\nThe package comes with a pre-configured config.json file that is included in the distribution. This file contains default Reddit API credentials which are used when the package is executed. To use these default credentials, you don\u00e2\u20ac\u2122t need to create a separate config.json.\r\n\r\nIf you need to use different credentials or override the default configuration, you can create your own config.json in the same directory where the script is executed, with the following structure:Create a config.json file in the project root directory with the following structure:\r\n\r\n```json\r\n{\r\n \"REDDIT_CLIENT_ID\": \"your_client_id\",\r\n \"REDDIT_SECRET\": \"your_client_secret\",\r\n \"REDDIT_USER_AGENT\": \"your_user_agent\"\r\n}\r\n```\r\nReplace the placeholders with your Reddit API credentials.\r\n\r\nNote: Although this package includes default API credentials, it's a good practice to provide your own configuration file for personal use to avoid exposing the default credentials\r\n\r\n\r\n## Usage\r\n\r\nYou can use the package either as a command-line tool or import it into your Python scripts.\r\n\r\n### Command line tool\r\n\r\n- To get help and see the available options:\r\n```bash\r\nreddit_image_downloader --help \r\n```\r\n\r\n- To check the version of the installed package\r\n```bash\r\nreddit_image_downloader --version\r\n```\r\n\r\n- To check information about author and code\r\n```bash\r\nreddit_image_downloader --author\r\n```\r\n\r\n- To run the tool interactively and be prompted for a Reddit post URL and output ZIP file name:\r\n```bash\r\nreddit_image_downloader --run\r\n```\r\n\r\n- To download images from a Reddit post directly by providing the post URL and the name of the output ZIP file:\r\n```bash\r\nreddit_image_downloader \"https://www.reddit.com/r/example/comments/example_post/\" \"my_images.zip\"\r\n```\r\n\r\n### Python API\r\n\r\nTo use the functionality programmatically, import the module and call the download_images_from_post function:\r\n```python\r\nfrom reddit_image_downloader.main import download_images_from_post\r\n\r\n# Example usage\r\npost_url = 'https://www.reddit.com/r/example/comments/example_post/'\r\noutput_zip = 'output_images.zip'\r\nconfig = {\r\n 'REDDIT_CLIENT_ID': 'your_client_id',\r\n 'REDDIT_SECRET': 'your_client_secret',\r\n 'REDDIT_USER_AGENT': 'your_user_agent'\r\n}\r\n\r\ndownload_images_from_post(post_url, output_zip, config)\r\n```\r\n\r\n## Testing\r\n\r\n```bash\r\npython -m unittest discover -s tests\r\n```\r\n\r\nThis will run all test cases defined in the 'tests' directory.\r\n\r\n## Use cases\r\n\r\n1. **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.\r\n\r\n2. **Content Analysis:** Researchers or analysts might need to collect images from Reddit for analyzing content trends or for training machine learning models.\r\n\r\n3. **Backup:** Users who want to back up images from interesting Reddit threads can use this script to download and store them conveniently.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\r\n\r\n## Acknowledgements\r\n\r\n- [PRAW](https://pypi.org/project/praw/) for interacting with the Reddit API.\r\n- [Requests](https://pypi.org/project/requests/) for handling HTTP requests.\r\n- [TQDM](https://pypi.org/project/tqdm/) for the progress bar\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A tool to download images from Reddit posts and comments and save them into a ZIP file.",
"version": "0.1.5",
"project_urls": {
"Homepage": "https://github.com/iamrishu11/Reddit-Image-Downloader"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f8154e958c5197eb6a9ead839cf3782c134c53530da98ec78805b440f4683752",
"md5": "9d22cc68e8ca55360a9b2841401ba5be",
"sha256": "1eb1d1ce2a726fc0a030b45ba6f5998d591326a8adb6827603ec28968baf83e7"
},
"downloads": -1,
"filename": "reddit_image_downloader-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9d22cc68e8ca55360a9b2841401ba5be",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 9885,
"upload_time": "2024-08-27T14:00:14",
"upload_time_iso_8601": "2024-08-27T14:00:14.094978Z",
"url": "https://files.pythonhosted.org/packages/f8/15/4e958c5197eb6a9ead839cf3782c134c53530da98ec78805b440f4683752/reddit_image_downloader-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f521102831a0dcaeef26d4823d60fbcd20cade932f92e1fe1526edf2da7cde42",
"md5": "35750e47ace071b660020822439a6fa5",
"sha256": "b0b542548c72b3761e0b01e16d88398c98e2f6cff2eb06d64fb5ce775504528a"
},
"downloads": -1,
"filename": "reddit_image_downloader-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "35750e47ace071b660020822439a6fa5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 8642,
"upload_time": "2024-08-27T14:00:15",
"upload_time_iso_8601": "2024-08-27T14:00:15.194537Z",
"url": "https://files.pythonhosted.org/packages/f5/21/102831a0dcaeef26d4823d60fbcd20cade932f92e1fe1526edf2da7cde42/reddit_image_downloader-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-27 14:00:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "iamrishu11",
"github_project": "Reddit-Image-Downloader",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "reddit-image-downloader"
}