Skip to content

Psycoguana/Filter-for-Reddit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Filter for Reddit

Easily filter your saved reddit posts and commments

Made with ❤ and tears by Psicoguana

PyPI version Wakatime


💬 About:

Did you ever searched for random post or comment you saved in Reddit months ago? Maybe it belonged to a certain subreddit, was it NSFW? It definitely linked to some weird page no one heard of before...

What a hassle, besides having to pay attention to each and every post you saved, you have to scroll and do several Ctrl+F.

I hated that, so I created Filter for Reddit or ffr for short.

✨ Features:

  • Get every saved element (post or comment).
  • Get every post.
  • Get every comment.
  • Get posts with text only.
  • Get posts with some type of media (image, gif or video).
  • Filter specific subreddits.
  • Search for a word in a saved post's title.
  • Search for a word in a saved comment's body.
  • Get every element marked as NSFW.
  • Get posts with a link to an external website.
  • Clickable links.
  • Script for easy login.
  • Multiple accounts support (Not currently supported by the menu).
  • Specify maximum amount of elements to retrieve (Not currently supported by the menu).

📦 Install:

You can easily install ffr with pip:

pip3 install ffr

🔧 Setup:

First you'll need to login. Reddit requires that you create a client_id and a client_secret. For that I borrowed and edited a script from Praw.

There are two way of doing this, you can either create the file manually or you can use the login command.

If you run ffr login, it will print something like this:

login

Follow the steps and it'll create a praw.ini file for you with the data that you entered, which will be used by the script. It will look something like this:

praw.ini

If you need to edit the file or want to create it manually, it's location will be printed by the login command. If you missed it, this text grabbed from the Praw Docs, should be helpul:

Assuming typical operating system installations and the username foobar the path for specific operating systems should be:

  • WINDOWS XP: C:\Documents and Settings\foobar\Application Data\praw.ini
  • WINDOWS Vista / 7: C:\Users\foobar\AppData\Roaming\praw.ini
  • OS with XDG_CONFIG_HOME defined: $XDG_CONFIG_HOME/praw.ini
  • OS X / Linux: /home/foobar/.config/praw.ini

⚠️ BE VERY CAREFUL WITH THIS FILE, IT CONTAINS ALL YOUR REDDIT ACCOUNT'S INFO. ⚠️

 

🖥️ Usage:

You can either use it's (under development) menu by calling ffr: menu

Or you can also run one of the many command available. To see them just run ffr --help:

help

There are a 4 options that require one or more arguments:

1. Get posts with some type of media:

You must specify the type of media you want.

For example: ffr filter-media img will get you every posts that links to an image. You can choose img, gif or vid. For example, in my case ffr filter-media img returns:

filter_media

2. Filter specific subreddits:

You must specify one or more subreddits.

If you want to get your saved posts and comments belonging to one or more subreddits, let's say r/Python and r/Programming it's as easy as running ffr subreddits hmm python.

subreddits_cli

Please note that if you want to search from the menu and not the command line, you must separate each subreddit with a comma.

subreddits_menu

3. Search Post:

You must specify a word to look in the post's title.

This command takes a query argument which tells the script what you want to search in a comment's body. For example, in my case ffr search-posts python returns:

search_posts

4. Search Comments:

You must specify a word to look in the comment's body.

It works pretty much the same as the search for posts. ffr search-comments python.

search_comments

➖➖ Optional arguments:

There are two of these:

  • --user, -u -> Specify which user you want to use. If you have more than one user in your praw.ini file like here:

user_flag

You'll have to specify it's name when running the script, if you want to search every post and comment from the user jDoe, you must run: ffr --user=jDoe show-all or ffr -u jDoe show-all

  • --limit, -l -> Specify how many elements to retrieve. By default, the script retrieves 100 elements, but if you feel like that's too much or too little just use this flag. For example: ffr --limit=500 show-all or ffr -l 500 show-all

🧩 Compatibility:

  • Linux: Tested on Ubuntu 20.04.
  • Windows: Tested on Windows 10. The console doesn't support text with embedded hyperlinks, so it'll just print a third row with the links.
  • Mac: It should work too, but I don't have a Mac to test it. If you try it, please let me know how it went 🙂

📚 Dependencies:

  • Praw: to handle Reddit's API.
  • Rich: to easily create a beautiful table.
  • click: to easily create the CLI.

🔖 TODO:

  • Create a Pypi package.
  • Create an exe package.
  • Support changing table colors.
  • Improve login script format.
  • Improve menu format.
  • You tell me...

🗣️ Let me know!

What you think about Filter for Reddit? Feel free to send me a DM on Reddit! ✉️

Do you have any question or suggestion? Did you encounter any issue or found any bug? Feel free to open an issue and I'll check it ASAP 😉

📃 License:

Mozilla Public License Version 2.0.