Created
March 6, 2011 04:59
-
-
Save marksteve/857045 to your computer and use it in GitHub Desktop.
Deletes all of your reblogs only (hopefully).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| USERNAME = 'your_username' | |
| EMAIL = 'your@email.com' | |
| PASSWORD = 'yourpassword' | |
| import urllib as u | |
| import urllib2 as u2 | |
| import re | |
| from lxml import etree as e3 | |
| total = -1 | |
| del_ids = [] | |
| i = 0 | |
| while total < 0 or i * 20 < total: | |
| print 'Finding reblogs from post %d to %d...' % (i * 20, (i + 1) * 20 - 1) | |
| resp = u2.urlopen('http://%s.tumblr.com/api/read?start=%d' % (USERNAME, i * 20)).read() | |
| pxml = e3.fromstring(resp).getchildren()[1] | |
| if total < 0: | |
| total = int(pxml.attrib['total']) | |
| reblogs = 0 | |
| posts = pxml.getchildren() | |
| for post in posts: | |
| post_str = e3.tostring(post) | |
| if (len(re.findall('tumblr_blog', post_str)) == 0 # This is quite aggressive. | |
| and len(re.findall('via-', post_str)) == 0): # For old reblogs. Quite dangerous. | |
| continue | |
| del_ids.append(post.attrib['id']) | |
| reblogs += 1 | |
| i += 1 | |
| print 'Found %d reblogs' % reblogs | |
| print 'Deleting %d reblogs...' % len(del_ids) | |
| for id in del_ids: | |
| data = u.urlencode({ | |
| 'email': EMAIL, | |
| 'password': PASSWORD, | |
| 'post-id': id, | |
| 'generator': 'tumbleed' | |
| }) | |
| print 'Post %s: %s' % (id, u2.urlopen('http://www.tumblr.com/api/delete', data).read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment