#!/usr/bin/env ruby
require 'json'
require 'net/http'
require 'sanitize'
require 'cgi'
resp = Net::HTTP.get(URI("http://a.4cdn.org/mlp/thread/#{ARGV[0]}.json"))
json = JSON.parse(resp)
comments = json["posts"].map{|x| x["com"]}
total_size = comments.size
comments.map!{|comment| Sanitize.fragment(comment, Sanitize::Config::RESTRICTED)}
comments.map!{|x| CGI.unescapeHTML(x)}
comments.keep_if do |comment|
comment.length < 50
end
puts "I found #{comments.count} useless fucking posts"
puts "That's out of #{total_size} posts."
puts "An astounding #{(comments.count.to_f/total_size)*100} percent. Jesus."
puts "They were:"
puts comments.join("\n_____________________\n")