From 1a86a20e846865fd8b6b22b7fda5a7e827f5bc6c Mon Sep 17 00:00:00 2001 From: David Trail Date: Sun, 18 Mar 2012 20:10:37 +0100 Subject: [PATCH] Refactored slightly --- kill.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kill.py b/kill.py index a5a3e3f..551cbbf 100755 --- a/kill.py +++ b/kill.py @@ -46,14 +46,13 @@ tmp = json.loads(http.read())['json']['data'] headers.update({'Cookie': 'reddit_session=%s' % tmp['cookie']}) modhash = tmp['modhash'] -print '# Headers: %s' % headers - for dat in deletion_ids: - print u'''{time} {subreddit}: {text}...'''.format( - subreddit = dat['subreddit'], - id = dat['id'], - time = datetime.fromtimestamp(dat['created']).date(), - text = dat[u'body'][:20]) + id = dat['id'] + time = datetime.fromtimestamp(dat['created']).date() + subreddit = dat['subreddit'] + text = dat[u'body'][:20] + + print '{time} {subreddit}: "{text}..."'.format(subreddit=subreddit, id=id, time=time, text=text) # And now for the deleting conn = httplib.HTTPConnection('www.reddit.com') params = urllib.urlencode({ @@ -62,6 +61,7 @@ for dat in deletion_ids: 'api_type': 'json'}) conn.request('POST', '/api/del', params, headers) http = conn.getresponse() - print http.getheaders(), http.read() - break - #sleep(2) + if http.read() != '{}': + print '''Failed to delete "%s" (%s - %s - %s)''' % (text, id, time, subreddit) + break # Still in-testing + sleep(2)