Created
September 22, 2009 17:37
-
-
Save webcracy/191254 to your computer and use it in GitHub Desktop.
Polling of TVI.pt latest videos
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
# Stupid polling of TVI.pt latest videos | |
# Also tries to match a string to test for specific videos | |
# If true, it sends a Growl notification and outputs the video title to STDOUT | |
require 'rubygems' | |
require 'open-uri' | |
require 'cgi' | |
require 'hpricot' | |
require 'ruby-growl' | |
url = "http://www.tvi.iol.pt/frame_videos_tvi.html" | |
growl = Growl.new 'localhost', 'ruby-growl', ["ruby-growl Notification"] | |
loop do | |
doc = open(url) {|f| Hpricot(f)} | |
videos = (doc/"#accordionList2"/"div"/"div.title"/"div.titleCopy"/"span") | |
videos.each do |video| | |
if CGI.unescape(video.innerHTML).include? "Jornal da Uma - 22" | |
growl.notify "ruby-growl Notification", "TVI ALERT!", "Saiu a reportagem da Quodis" | |
puts CGI.unescape(video.innerHTML) | |
end | |
end | |
sleep 300 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment