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
File details
Details for the file redditsweeper-1.0.1.tar.gz
.
File metadata
- Download URL: redditsweeper-1.0.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.5 CPython/3.6.5 Linux/4.15.0-33-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf0df9745340ac6864b2f1af4245a184d6459e271b1ed8e809d80a707f7fd7ed |
|
MD5 | 87199440ba7ef1698767abcf6739314f |
|
BLAKE2b-256 | 790aae695b6e31a9dc89d382db93a561536342f9475caddea8371d33454bd13e |
File details
Details for the file redditsweeper-1.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: redditsweeper-1.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.5 CPython/3.6.5 Linux/4.15.0-33-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a877fa80f8e82079da75eb900946301d3bb308ceffb46fa31e0efde13abbc5e0 |
|
MD5 | 3b35f5f4dc871680ac4037c46bba35f5 |
|
BLAKE2b-256 | fa900f7e42aed7cc9511c4301f2a935270e6150a737202ca1dd974896900091d |