Skip to content

schbrongx/reddit-image-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

reddit-image-loader

A Python 3 class and script to download images from subreddits.

Table of contents

  1. Usage as a script
  2. Usage as a class
  3. Installation
    1. Prerequesites
    2. Setup

Usage as a script

Usage: ril.py [-h] [-l LIMIT] [-d] [-N | -T | -H | -R] SUBREDDIT TARGETFOLDER

Positional arguments:

  • SUBREDDIT An existing subreddid name. I.e.: earthporn
  • TARGETFOLDER Folder where the images and our trackingfile should be stored.

Optional arguments:

  • -h, --help: show this help message and exit
  • -l LIMIT, --limit LIMIT: limit the number of images to download and keep in TARGETFOLDER
  • -d, --daemonize: run in background
  • -N, --new: Load newest posts.
  • -T, --top: Load top posts.
  • -H, --hot: Load hot posts.
  • -R, --random: Load random posts.

Example: ril.py -l 5 -T earthporn ./images This will:

  • Load a list of 5 images in landscape-orientation
  • Remove all images, which are not in our list, from ./images/
  • Download all images from our list, which are not already in ./images and
  • Resize them to 1920xNNNN, preserving the ascpet-ration

Usage as a class

import ril
my_ril = RedditImageLoader(subreddit="earthporn", targetfolder="./images" limit=25 flair=new orientation=landscape"
my_ril.load_image_urls()
my_ril.download_images()

This will:

  • Load a list of 25 (limit) images in landscape-orientation
  • Download images from the list which are not already downloaded and resize them to 1920xNNNN (preserving the aspect-ratio)

Installation

Prerequesites

Python 3 has to be installed.

Setup

  • Clone Repository: git clone https://github.com/schbrongx/reddit-image-loader.git
  • Change into git repository: cd reddit-image-loader
  • Create a virtual environment: python3 -m venv env
  • Activate the virtual environment: . ./env/bin/activate
  • Install requirements: pip install -r requirements.txt
  • Test script: src/ril.py --help

About

A Python 3 class and script to download images from subreddits.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors