Created
January 29, 2015 21:22
-
-
Save Treeki/9ed2d370fbabc7eb1cdb to your computer and use it in GitHub Desktop.
This file contains 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
# A terrible script that really should be using the Twitter gem rather than | |
# calling into twurl. | |
# | |
# (This was originally a shell script, but my POSIX-fu wasn't good | |
# enough to figure out how to get it to work on Mac OS...) | |
# | |
# Usage: | |
# $ ruby twitter_unblocker.rb /path/to/twurl | |
# Example: | |
# $ ruby twitter_unblocker.rb `where twurl` | |
require 'json' | |
twurl_path = ARGV.last | |
data = JSON.parse(`#{twurl_path} "/1.1/blocks/ids.json"`) | |
ids = data['ids'] | |
puts "Unblocking #{ids.size} user#{(ids.size == 1) ? '' : 's'}..." | |
ids.each_with_index do |id,index| | |
print "[#{index + 1} / #{ids.size}] #{id} - " | |
result = `#{twurl_path} -X POST "/1.1/blocks/destroy.json?user_id=#{id.to_i}"` | |
json_result = JSON.parse(result) | |
if json_result.key?('screen_name') | |
puts "@#{json_result['screen_name']} (@#{json_result['name']})" | |
else | |
puts "Failed? #{result}" | |
end | |
sleep 1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment