Tool for automated removal of old reddit comments.
Project description
Reddit Sweeper
This tool is designed to be an easy-to-use utility to clear out old reddit comments. It aims for simplicity in terms of use as well as configuration. It currently supports the following features:
- Delete comments and/or submissions
- Exclude one or more subreddits when search for content to delete
- Include only a subset of subreddits when searching for content to delete
- Only delete comments over a given number of days old
- Save a record of deleted content in an easy to parse JSON file
It supports Python 2.7, 3.6, 3.7, and PyPy and uses poetry for dependency management.
Installation
Pip
The easiest way to install redditsweeper is via Pip, using the following command:
pip install -U redditsweeper
Poetry
To install redditsweeper from Github, clone it to your local filesystem, and then from the redditsweeper directory, use:
poetry install
Usage
Once installed, a CLI tool called redditsweeper
should available to use. It
may be configured either via command line arguments, a config file, or
environment variables of the form REDDITSWEEPER_.
Configuring Reddit credentials
First, it is necessary to obtain script credentials from reddit. You can set this up easily here by doing the following:
- Click "create another app..."
- Enter a name of "redditsweeper"
- Choose the "script" option
- Leave description blank.
- Just put "http://127.0.0.1" in each URL field (this are just dummy values and are not used)
- Click "create app"
- Get the client ID by looking at the line underneath "personal use script"
- Get the client secret next to the word "secret"
Create a copy of praw.ini.sample called "praw.ini" and set up the values for client ID and secret that you just obtained, as well as entering your username and password.
If your account has multi-factor authentication enabled, you will need to supply redditsweeper with a MFA code each time you run it with the "--mfa" parameter in addition to the username and password you set up here.
Configuring redditsweeper
If you want to store the settings used, make a copy of redditsweeper.cfg.sample called "redditsweeper.cfg" and fill in the options you need. A brief overview of options is as follows:
- dry - This is
True
orFalse
. IfTrue
, redditsweeper will operate in dry run mode. It will show you what it would do with each comment or submission, but it will not delete anything. - exclude - This is a list of subreddits (in the form r/subreddit name) that should be excluded from deletion. Anything found belonging to one of these subreddits will be skipped.
- include - If you want to provide an explicit list of subreddits to target
for deletion, provide it here. If nothing is provided, redditsweeper simply
considers everything for deletion. Note that if the comment or submission is
either in an excluded subreddit or is too new and the
--keep
option was set, it will be skipped regardless of whether it's in the include list. - keep - This is a number of days worth of comments or submissions to keep. Anything newer will be kept no matter what, and anything older will be considered for deletion.
- savefile - If set, a JSON file will be created at the given filename, and it will be updated with the contents of comments and submissions deleted. Any existing savefile will be overwritten.
- type - The type of reddit content to delete. It can be "comment", "submission", or "both".
- user - This controls which section of praw.ini will be used. If you have multiple user accounts and want to switch between deleting content from one account to the other, just overwrite this setting.
Testing
redditsweeper uses pytest to run tests, with responses used to stub fake responses from reddit, so no credentials are required for testing. Run the set of tests using the following command:
poetry run py.test --cov=redditsweeper tests/
It currently supports Python 2.7, 3.6, 3.7, and PyPy, and multi-version tests can be run using:
poetry run tox
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for redditsweeper-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cbb4bcc9eb10c1c9388a9bcbdb6cda81fbb8de7a041d0a0c78ac6738bcd50eb |
|
MD5 | c9433a83a0b5aa2b22845daa07a2f20a |
|
BLAKE2b-256 | dbcd614890777de8966e14bf28ec190c2fd4d77b728f39f9c4cc792cf9c92de8 |