Last active
August 29, 2015 14:17
-
-
Save shobhitic/952915eae4c72def3637 to your computer and use it in GitHub Desktop.
Get cricket score notifications in Mac
This file contains hidden or 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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@karanjthakkar Yes