Created
June 18, 2009 11:49
-
-
Save kyleslattery/131865 to your computer and use it in GitHub Desktop.
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
# This script auto deletes any entries you've imported | |
# to Tumblr via an RSS Feed | |
require 'rubygems' | |
require 'httparty' | |
# Config | |
tumblr_address = "http://you.tumblr.com" | |
email = "[email protected]" | |
password = "password" | |
# Each imported RSS feed has a unique ID. To find yours, | |
# go to http://you.tumblr.com/api/read and locate an entry | |
# that was imported via RSS. There should be an attribute | |
# called rss-feed-id there | |
rss_feed_id = "12345" | |
class Tumblr | |
include HTTParty | |
format :xml | |
def self.read(start=0, num=50) | |
get(tumblr_address + '/api/read', :query => {:start => start, :num => num}) | |
end | |
def self.delete(postid) | |
post(tumblr_address + '/api/delete', :query => {:email => email, :password => password, 'post-id' => postid}) | |
end | |
end | |
keep_going = true | |
start = 0 | |
tweets = [] | |
while keep_going == true | |
raw = Tumblr.read(start) | |
if raw['tumblr']['posts']['start'].to_i > raw['tumblr']['posts']['total'].to_i | |
keep_going = false | |
else | |
tw = raw['tumblr']['posts']['post'].find_all{|a| a['from_feed_id'] == rss_feed_id} | |
tweets += tw | |
start += 50 | |
end | |
end | |
tweets.each do |t| | |
puts '-----' | |
puts t['id'] | |
puts t['regular_body'] | |
puts Tumblr.delete(t['id']) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment