Git Product home page Git Product logo

reddit-downloader's Introduction

Reddit Video and Image Downloader

This script uses the praw library to access the Reddit API and download videos and images from a list of subreddit names.

Python

LinkedIn Freelancer Upwork

โž• Dependencies

The following libraries are required to run this script:

  • praw: Used to access the Reddit API and retrieve posts from subreddits.
  • requests: Used to send HTTP requests to the Reddit API and download content from URLs.
  • os: Used to create directories and manipulate file paths.

๐Ÿ“™ Downloading Videos and Images

The script iterates through each subreddit in the subreddit_names list and retrieves the last 25 hot posts from the subreddit. It creates a folder for the subreddit if it doesn't already exist, and then downloads and saves the videos and images from the posts.

For each post, the script checks the file extension of the url to determine if it's an image or a video. If it's an image, it downloads the content and saves it to the images folder for the subreddit. If it's a video, it retrieves the fallback_url from the media attribute and downloads the content, saving it to the videos folder for the subreddit. The file names are constructed using the post's upvotes and title, with any invalid characters in the title replaced with an underscore.

โš™๏ธ Configuration

To customize the behavior of the script, you can modify the following variables:

  • client_id: The client ID provided to you by Reddit.
  • client_secret: The client secret provided to you by Reddit.
  • subreddit_names: A list of subreddit names that the script should download content from.

Running the Script

To run the script, ensure that the required dependencies are installed and then execute the script using a command line interface or a Python interpreter.

The downloaded videos and images will be saved to the appropriate folders in the current working directory.

pip install -m requirements.txt
python reddit.py

๐Ÿ“ License

The MIT License (MIT)

Copyright ยฉ 2023 Mirel Constantin

reddit-downloader's People

Contributors

mirelconstantin avatar

Stargazers

Virgil avatar  avatar  avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.