This is a simple script, later turned to package, written by me a few years ago to download media files from Reddit. I wrote this while learning to automate processes using Python.
- RedPy can be used to download both images and videos from Reddit
- Allows you to specify the number of media files to download
- You can sort the list by new, hot and top
- Very customizable and easy to use
How to use
- Install the package using either pip or by cloning the repo from Github.
- Create an instance of the class
Redpyafter importing the module.
- Download the images or videos accordingly from the required subreddit and sort option.
- The complete procedure is defined on the Readme of the repository.
How does it work?
Reddit has a very simple API that returns JSON data on calling any subreddit URL. This script is just a wrapper over this to get the media files from the returned JSON object. If you go to https://www.reddit.com/r/pics/top.json, you will see the JSON object of a list of top posts from the last 24 hours from the subreddit /r/pics. I just had to parse it and get the media objects.
- Other than downloading images, also return the download URLs of the media files
- Make it system path independent