Skip to content

Instantly share code, notes, and snippets.

@ivey
Created December 8, 2009 06:30
Show Gist options
  • Save ivey/251456 to your computer and use it in GitHub Desktop.
Save ivey/251456 to your computer and use it in GitHub Desktop.
# Delete all imported Tumblr posts from Twitter, Google Reader, Flickr, etc.
# by Michael D. Ivey
# based on Michael Gorsuch's http://bit.ly/7Ng55u
# No rights reserved, DWTFYWWI
require 'rubygems'
require 'tumblr'
require 'hpricot'
config = {
:email => '[email protected]',
:password => 'XXXXXXXXXX',
:name => 'ivey'
}
tumblr = Tumblr.for config
s = 10
loop do
xml = tumblr.read(:xml, :num => 50).content
doc = Hpricot(xml)
puts "Looping: " + (doc/:post).size.to_s
(doc/:post).each do |p|
if p.attributes['feed-item']
puts p.attributes['feed-item']
resp = tumblr.delete(:xml, 'post-id' => p.attributes["id"])
sleep s
if resp.status_code == 503
puts "Throttled (#{s})"
s = s * 5
redo
else
s = 10
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment