I LOVE the Philadelphia Flyers. Any time they play, I need to know the score at least every two minutes. If I’m somewhere without a TV, clicking the refresh button for the scoreboard every two minutes is just too much work. So I made python do the work for me.
The script goes to the Flyers (or any other NHL team) website, pulls out the scoreboard and prints it to the screen. Once you add it to conky you’ll have a scoreboard on your desktop. No need for a browser or clicking that refresh button. When the game is in progress the script will update the score automatically, when it’s not in progress it’ll show the date and time of the next game.
The basic idea of the script is:
Set two flags (one before the scoreboard and one after)
Store the substring between the flags into a variable
Break this substring into tokens (Team name, date, time, etc…)
Each token is displayed as the scoreboard
Side Note:
The bad thing about this script is it’ll break anytime the NHL changes their scoreboards HTML. I’ll try to keep it as updated as possible. If they change the HTML i’ll fix it and upload another version. I doubt they’ll be changing it often though. Also, Im using Python version 2.5.2. I havent tested with any other version
If you don’t know what conky is check out my Conky Tutorial
Theres two things you need to add to your .conkyrc file after you download this script.
1. This should go into the TEXT section of the .conkyrc
120 is the interval in seconds for it to update (so every 2 minutes)
Call python and then your scripts location and your teams name as an argument
${execi 120 python /path/to/your/script.py flyers}2. This needs to go in the parameter section before TEXT.
If you leave this out the script output will look cut off in conky.
text_buffer_size 512
You can either supply your teams name as an argument or change it manually in the code. The team name should always be one word. If you enter an incorrect team name the errors will look like this:
bhavik@bdesktop:~/Desktop$ python scoreboard.py crap Traceback (most recent call last): File "scoreboard.py", line 60, in html = urllib2.urlopen('http://' + team + '.nhl.com/index.html') #open site File "/usr/lib/python2.5/urllib2.py", line 124, in urlopen return _opener.open(url, data) File "/usr/lib/python2.5/urllib2.py", line 381, in open response = self._open(req, data) File "/usr/lib/python2.5/urllib2.py", line 399, in _open '_open', req) File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain result = func(*args) File "/usr/lib/python2.5/urllib2.py", line 1107, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/lib/python2.5/urllib2.py", line 1082, in do_open raise URLError(err) urllib2.URLError:
If you do it correctly the output should look like this
bhavik@bdesktop:~/Desktop$ python scoreboard.py flyers Thu Feb 19, 2009 7:00 PM Teams 1st 2nd 3rd Total ------------------------------ Buffalo 0 0 0 0 Philadelphia 0 0 0 0
And of course after all that I came across a website that just streams the entire game for you live… www.hockeywebcasts.com
The script still comes in handy when I’m too busy to actually watch the game or if the feeds on that site are down. Try it out and tell me what you think. If you have a cool conky setup, post it in the comments!
Enjoy!
EDIT: Script is broken during the off-season…The Flyers have lost, I don’t know if I can go on…I’ll fix the script once I recover



#1 by Ted on May 11, 2011 - 7:57 pm
Hey, I just wanted you to know I stumbled across this and decided to rewrite it using BeautifulSoup! Check it out here:
https://github.com/twexler/randoms/blob/master/scoreboard.py