Skip to content

Instantly share code, notes, and snippets.

@shobhitic
Last active August 29, 2015 14:17
Show Gist options
  • Save shobhitic/952915eae4c72def3637 to your computer and use it in GitHub Desktop.
Save shobhitic/952915eae4c72def3637 to your computer and use it in GitHub Desktop.
Get cricket score notifications in Mac
# Install 3 gems :- terminal-notifier, nokogiri, httparty
require 'terminal-notifier'
require 'nokogiri'
require 'httparty'
previous = ""
cricinfo = true
if cricinfo
while true
xml = Nokogiri::XML.parse HTTParty.get('http://static.cricinfo.com/rss/livescores.xml').body
description = xml.xpath('//item//description').first.text
link = xml.xpath('//item//link').first.text
if previous != description
previous = description
TerminalNotifier.notify 'Score', title: description, open: link
end
sleep 60
end
else
# Use cricbuzz for more elaborate description
while true
xml = Nokogiri::XML.parse HTTParty.get('http://live-feeds.cricbuzz.com/CricbuzzFeed').body
description = xml.xpath('//item//description').first.text
link = xml.xpath('//item//link').first.text
if previous != description[0...8]
previous = description[0...8]
TerminalNotifier.notify description[0...(description.index "<")], title: "Score", open: link
end
sleep 60
end
end
@karanjthakkar
Copy link

@shobhitic sleep 45 is 45 seconds?

@shobhitic
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment