From e6c732f4df4af24ca6f1d3234d2f9c56cedb6695 Mon Sep 17 00:00:00 2001 From: David John Date: Fri, 25 Nov 2016 10:32:48 +0000 Subject: [PATCH] This should skip clearing votes on subs > 6m old --- shreddit/shredder.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shreddit/shredder.py b/shreddit/shredder.py index b20caa6..a59b001 100644 --- a/shreddit/shredder.py +++ b/shreddit/shredder.py @@ -9,7 +9,8 @@ import praw import time from re import sub from datetime import datetime, timedelta -from praw.errors import (InvalidUser, InvalidUserPass, RateLimitExceeded, HTTPException, OAuthAppRequired) +from praw.errors import (InvalidUser, InvalidUserPass, RateLimitExceeded, + HTTPException, OAuthAppRequired) from praw.objects import Comment, Submission from shreddit.util import get_sentence @@ -131,8 +132,11 @@ class Shredder(object): if self._keep_a_copy and self._save_directory: self._save_item(item) if self._clear_vote: - item.clear_vote() - self._api_calls.append(int(time.time())) + try: + item.clear_vote() + self._api_calls.append(int(time.time())) + except HTTPException: + self._logger.debug("Couldn't clear vote on {item}".format(item=item)) if isinstance(item, Submission): self._remove_submission(item) elif isinstance(item, Comment):