[Ilugc] Re: get the cricket score to your linux desktop

  • From: sridharinfinity@xxxxxxxxx (Sridhar R)
  • Date: Sun Jul 18 18:48:42 2004

Run this python script to get the score in command line

------------------ score.py -------------------------
import urllib
 
class Score(object):
     
    """"Parses the score from score file"""
     
    SCORE_URL = "<this should be the URL of score file>"
     
    def __init__(self):
        self.vars = {} # dictionary variables read from the score file
         
    def refresh(self):
        """Refresh the score"""
        url_opener = urllib.URLopener()
        url = url_opener.open(self.SCORE_URL)
        self.vars = {}
        for stmt in url.read().split('\n'):
            stmt = stmt.strip()
            if stmt == "": continue
            var, val = stmt.split('=')
            self.vars[var] = val
        url.close()
        return self.vars
         
    def render(self):
        """Return the rendered text"""
        return "%(tagline)s - %(l1)s (%(date)s)\n%(l2)s" % self.vars
         
         
class RediffScore(Score):
 
    """Data from www.rediff.com"""
    SCORE_URL = "http://livechat.rediff.com:80/sports/score/score.txt";
         
    def getMatchName(self):
        return self.vars['tagline']
         
    def getScore(self):
        return self.vars['l2']
         
    def getTeams(self):
        return self.vars['l1']
         
    def getDate(self):
        return self.vars['date']
         
    def getMessage(self):
        return self.vars['message']
         
 
if __name__ == '__main__':
    print 'Current score'
    sc = RediffScore()
    sc.refresh()
    print sc.render()
------------------ score.py -------------------------

The above file is part of my current project (which is an enhanced scoreboard)


On Sun, 18 Jul 2004 16:00:44 +0530, Sridhar R <sridharinfinity@xxxxxxxxx> wrote:

Found this great ..
http://scoreboard.sourceforge.net/

Currently monitoring Ind Vs SL score :)

--
Sridhar - http://www.cs.annauniv.edu/~rsridhar
Blog: http://www.livejournal.com/users/sridharinfinity



-- 
Sridhar - http://www.cs.annauniv.edu/~rsridhar
Blog: http://www.livejournal.com/users/sridharinfinity

Other related posts: