GithubHelp home page GithubHelp logo

mcdallas / gert Goto Github PK

View Code? Open in Web Editor NEW
49.0 5.0 3.0 230 KB

A command line tool to download media from Reddit

License: MIT License

Rust 100.00%
cli media-downloader reddit rust reddit-api reddit-crawler reddit-scraper

gert's Introduction

Gert

A command line tool to download media from Reddit

  • Supports:
    • Reddit: PNG/JPG images, GIFs, Image galleries, videos
    • Giphy: GIFs
    • Imgur: Direct images, GIFVs and albums
    • Gfycat/Redgifs: GIFs
    • Streamable: videos
  • GIF/GIFV from Imgur/Gfycat/Redgifs are downloaded as mp4

Installation

Prerequisites

There is a soft dependency on ffmpeg, for installation instructions follow this link.

You can skip it but without it:

  • Videos hosted on reddit itself (v.redd.it) won't have sound
  • Gifs won't be automatically converted to .mp4

Using cargo

If you already have Rust installed, you can install using cargo:

cargo install gert

Using homebrew

brew tap mcdallas/gert
brew install gert

Github Release

just grab the latest release for your OS

Running

Simply pass the names of the subreddits you want to download media from with (multiple) -s flags

gert -s wallpapers -s earthporn

gert4

To download media from a single post/collection just pass the url of the post

gert https://old.reddit.com/r/wallpapers/comments/tckky1/some_walls_from_my_collections_vol6/

Command line options

Simple CLI tool to download media from Reddit

USAGE:
    gert [FLAGS] [OPTIONS] <URL> --subreddit <SUBREDDIT>...

FLAGS:
    -c, --conserve-gifs     Disable gif to mp4 conversion
        --debug             Show the current config being used
    -r, --dry-run           Dry run and print the URLs of saved media to download
    -h, --help              Prints help information
    -H, --human-readable    Use human readable names for files
    -V, --version           Prints version information

OPTIONS:
    -e, --from-env <ENV_FILE>         Set a custom .env style file with secrets
    -f, --feed <feed>                 Feed to download from [default: hot]  [possible values: hot, new, top, rising]
    -l, --limit <LIMIT>               Limit the number of posts to download [default: 25]
    -m, --match <MATCH>               Pass a regular expresion to filter the title of the post
    -o, --output <DATA_DIR>           Directory to save the media to [default: .]
    -p, --period <PERIOD>             Time period to download from [default: day]  [possible values: now, hour, day,
                                      week, month, year, all]
    -s, --subreddit <SUBREDDIT>...    Download media from these subreddits
    -u, --upvotes <NUM>               Minimum number of upvotes to download [default: 0]

ARGS:
    <URL>    URL of a single post to download

Optional Authentication with Reddit

Authentication is not required but if you want a more generous rate limit you can create a new app in reddit and pass your credentials to gert

  1. Create a new script application at https://www.reddit.com/prefs/apps
    • Click on create an app at the bottom of the page
    • Input a name for your application, for example: gert
    • Choose "script" as the type of application
    • Set "http://localhost:8080" or any other URL for the redirect url
    • Click on "create app" - you should now see the application has been created
    • Under your application name, you should see a random string - that is your client ID
    • The random string next to the field "secret" is your client secret
  2. Copy the client ID and client secret information returned
  3. Create a .env file with the following keys, for example gert.env:
CLIENT_ID="<client_id>"
CLIENT_SECRET="<client_secret>"
USERNAME="<username>"
PASSWORD="<password>"

NOTE: If you have 2FA enabled, please make sure you set PASSWORD=<password>:<2FA_TOTP_token> instead

Credits

based on https://github.com/manojkarthick/reddsaver

gert's People

Contributors

kdkasad avatar manojkarthick avatar mcdallas avatar rareromfish avatar xvca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gert's Issues

Limit not working properly?

This looks like an awesome project! I'm gonna use it for wallpaper scraping and stuff.

Maybe I'm doing something wrong, but whenever I use the -l flag and add any kind of limit, it always limits it to 15 pictures. If I don't use any kind of limit, it downloads 43 images rather than the 25 that should be the default.

Create new release

Hello,
I was wondering if you could create a new release that includes your most recent changes?

Rate limit/env auth issues?

I'm having some problems getting this program to work (using 0.2.2, since I'm on windows). When I run a bunch of jobs without using the .env auth file, I eventually get this error: [2023-09-09T07:48:18Z INFO gert] Starting data gathering from Reddit. This might take some time. Hold on.... thread 'main' panicked at 'Failed to parse JSON: reqwest::Error { kind: Decode, source: Error("missing field kind", line: 1, column: 46) }', src/subreddit.rs:40:93 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace I'm assuming this is some kind of rate limiting, although it shouldn't be making that many requests (roughly 100 subs, top 10 of each). The error happens about half way through.

When I try to use my env file, I get this error: Error: ReqwestError(reqwest::Error { kind: Decode, source: Error("missing field access_token", line: 1, column: 26) }) I have double and triple checked that my gert.env file has all the correct information from the template provided. Any help would be greatly appreciated.

Support passing a list of links as an argument

It would be nice if there was an option to supply a text file containing reddit links to the app to iterate over

Currently the only way is to loop over the contents of the text file, calling gert on each individual line, which is inefficient due to having to log in and initialise gert each time

Download user's posts

Would it be possible to download all posts of a particular user (not a subreddit)?

From what I understand, {}.json is also available for u/ pages, and it seems to have a similar (the same?) format as the subreddits

Redgif downloads do not have sound

Unsure if this effects other hosts or not, but redgif videos do not have sound for me. They are being converted to mp4s with ffmpeg, unsure how they would lose sound from the gifs however. It looks like redgif now defaults to muted when watching in a browser, perhaps there was some api change as well? A fix would be greatly appreciated.

-H flag sometimes causes errors on windows

The -H flag seems to occasionally fail to write a file, because the filename would have an illegal character for a windows file name. Some kind of check for any of these banned characters and replacing them with a placeholder would be appreciated, as it currently just skips that file.

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.