Skip to content

Instantly share code, notes, and snippets.

@rhysforyou
Created February 10, 2015 05:11
Show Gist options
  • Save rhysforyou/c75c752a0c31336ed9cf to your computer and use it in GitHub Desktop.
Save rhysforyou/c75c752a0c31336ed9cf to your computer and use it in GitHub Desktop.
Unlike everything you've reblogged on Tumblr
require 'tumblr_client'
BLOG_URL = "rpowelll.moe"
Tumblr.configure do |config|
config.consumer_key = "xxxx"
config.consumer_secret = "xxxx"
config.oauth_token = "xxxx"
config.oauth_token_secret = "xxxx"
end
client = Tumblr::Client.new(:client => :httpclient)
like_ids = {}
post_reblog_keys = []
like_reblog_keys = []
total_posts = client.posts(BLOG_URL, limit: 20, reblog_info: true)['total_posts']
offset = 0
while offset < total_posts do
post_reblog_keys += client.posts(BLOG_URL, offset: offset, limit: 20, reblog_info: true)['posts'].map do |post|
post['reblog_key']
end
offset += 20
puts offset
end
total_likes = total_posts = client.blog_likes(BLOG_URL, limit: 1)['liked_count']
offset = 0
while offset < total_likes do
client.blog_likes(BLOG_URL, offset: offset, limit: 20)['liked_posts'].each do |like|
like_reblog_keys << like['reblog_key']
like_ids[like['reblog_key']] = like['id']
end
offset += 20
puts offset
end
posts_to_unlike = like_reblog_keys & post_reblog_keys
posts_to_unlike.each do |reblog_key|
client.unlike like_ids[reblog_key], reblog_key
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment