Skip to main content

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.
  • Supports for Shortened Reddit URLs.
  • 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, you can install directly from PyPI:

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:

{
  "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:
reddit_image_downloader --help 
  • To check the version of the installed package
reddit_image_downloader --version
  • To check information about author and code
reddit_image_downloader --author
  • To run the tool interactively and be prompted for a Reddit post URL and output ZIP file name:
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:
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:

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)

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 file for details.

Acknowledgements

  • PRAW for interacting with the Reddit API.
  • Requests for handling HTTP requests.
  • TQDM for the progress bar

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

reddit_image_downloader-0.2.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reddit_image_downloader-0.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file reddit_image_downloader-0.2.0.tar.gz.

File metadata

  • Download URL: reddit_image_downloader-0.2.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for reddit_image_downloader-0.2.0.tar.gz
Algorithm Hash digest
SHA256 89c05ed1bc7461e22d22d69ef4cd9a7beb04d5eae6b000d24494b361e6bce331
MD5 85817174225ab15b5f343393449180e7
BLAKE2b-256 657f9d94c79820d1a4dc749794593c5201b572518f272bd31baad5d01eef8a72

See more details on using hashes here.

File details

Details for the file reddit_image_downloader-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for reddit_image_downloader-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 058a475d52749f5668bb090721c910cbde69c0a62458065e7d55fbe7ca53da26
MD5 66f66bc5b4ceb07797ee9716dd2ca820
BLAKE2b-256 2c58079bf206470d1a7b319d23c045ff53b2efe79676296b6aa23e34026b573f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page