Created
October 17, 2011 20:27
-
-
Save bcjordan/1293695 to your computer and use it in GitHub Desktop.
Uses InstantWatcher to find possible instant movies
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
require 'rubygems' | |
require 'open-uri' | |
require 'pp' | |
require 'nokogiri' | |
PAGE_URL = "http://www.reddit.com/r/AskReddit/comments/lf38m/what_is_the_funniest_movie_you_have_ever_seen/" | |
INSTANT_WATCHER = "http://instantwatcher.com/titles?q=QUERY&search_episodes=0" | |
page_text = Nokogiri::HTML(open(PAGE_URL)) | |
page_text.css('div.usertext-body').each do |content| | |
comments = content.content.split("\n") | |
comments.each do |comment| | |
movie = nil | |
begin | |
movie = comment.split("\n").first.gsub(/[^a-zA-Z0-9 ]/, '').gsub(' ', '+') | |
rescue | |
end | |
if movie && movie.split(' ').length < 6 | |
result = open(INSTANT_WATCHER.gsub('QUERY', movie)).read | |
puts "Instant: #{movie}" if !result.include? "No results." | |
sleep 0.5 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment