Tool for automated removal of old reddit comments.
- 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.
The easiest way to install redditsweeper is via Pip, using the following command:
pip install -U redditsweeper
To install redditsweeper from Github, clone it to your local filesystem, and then from the redditsweeper directory, use:
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_<option>.
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.
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, 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
--keepoption 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.
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
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size redditsweeper-1.0.1-py2.py3-none-any.whl (15.0 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size redditsweeper-1.0.1.tar.gz (7.2 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for redditsweeper-1.0.1-py2.py3-none-any.whl