diff --git a/shreddit b/shreddit index 0439985..1bf2709 100755 --- a/shreddit +++ b/shreddit @@ -19,25 +19,34 @@ r = reddit.Reddit(user_agent="Shreddit-PRAW") r.login() if verbose: - print "Logged in as %s" % r.user + print "Logged in as %s" % r.user before_time = datetime.now() - timedelta(days=days) if verbose: - print "Deleting messages before %s" % before_time + print "Deleting messages before %s" % before_time whitelist = [y.strip().lower() for y in whitelist.split(',')] if verbose: - print "Keeping messages from subreddits %s" % ', '.join(whitelist) + print "Keeping messages from subreddits %s" % ', '.join(whitelist) + +delete_whitelist = ('comments', 'submitted') +if item not in delete_whitelist: + raise Exception("Your deletion section is wrong") things = [] if item == "comments": things = r.user.get_comments(limit=None, sort=sort) -elif item == "submissions": - things = r.user.get_submissions(limit=None, sort=sort) +elif item == "submitted": + things = r.user.get_submitted(limit=None, sort=sort) for thing in things: + if item == "submitted": + if verbose: + print thing + thing.delete() + continue if str(thing.subreddit).lower() in whitelist: continue now_time = datetime.fromtimestamp(thing.created) diff --git a/shreddit.cfg b/shreddit.cfg index 4d42bad..3f1510b 100644 --- a/shreddit.cfg +++ b/shreddit.cfg @@ -3,23 +3,24 @@ [main] # How many days of comments you want to keep -days = 7 +days = 2 # Options: new, top, controversial, more? sort = new # Enables print statements to notify you of what's going on -verbose = True +verbose = False # Removes your vote before deleting the item clear_vote = False -# Options: comments, submissions +# Options: comments, sumbitted, overview +# See: https://github.com/mellort/reddit_api/blob/master/reddit/objects.py#L359 # Deletes either everything you've submitted # or every comment in your history. -item = comments +item = submitted # Anything in this list won't be deleted, coma delimited # spaces should work as .strip() is called after splitting # on comma. -whitelist = AskScience, TheCulture, redditdev, sysadmin, programming +whitelist = AskScience, TheCulture, redditdev, programming