API | charlie on software

Posts Tagged ‘ API

Fun with Python and Ice Hockey

HockeyStreamsAPI – a Python wrapper for the hockeystreams.com REST API


Assumes Python 2.7:

sudo pip install hockeystreams


For anonymous access, hockeystreams.com allows the get_scores ability:

from hockeystreams import HockeyStreams
hs = HockeyStreams()
score = hs.get_scores(shouldFilter=True, team="Calgary Flames")[0]
print "%s: %s"%(score.get_home_team(), score.get_home_score())
print "%s: %s"%(score.get_away_team(), score.get_away_score())

to determine what fields each returned object has, simply print it out:

print score

will output something similar to (depending on the api data):

home_team_city: St Louis
home_team: St Louis Blues
away_team: Calgary Flames
home_team_name: Blues
tv: None
period: Final
short_away_team: CGY
event: NHL
home_score: 3
away_team_name: Flames
short_home_team: STL
away_team_city: Calgary
away_score: 2
is_playing: 0

from there, each of the models can be accessed as:




If you create an account on hockeystreams.com, you can use this wrapper for authenticated access:

hs = HockeyStreams("cemeyer2", "password")
on_demand = hs.get_on_demand()[0]
print on_demand

will output something similar to (depending on the api data):

home_team: Rouyn-Noranda Huskies
away_team: Victoriaville Tigres
id: 12338
is_wmv: 0
date: 11/07/2013
is_flash: 1
event: QMJHL
isi_stream: 1

These objects can be used just as the unauthenticated versions.

It is important to note that many of the API functions exposed by hockeystreams.com are only available to premium members of the site. As such, this wrapper will raise a ValueError if a non-premium account tries to use any of the API functions which are restricted to premium members. In addition, a ValueError will be raised if any other error condition arises, with an associated message.


Feel free to fork and improve on github.

Pidgin-closeoffline: a plugin for Pidgin to close offline conversation tabs

I recently took some time to learn some of the inner workings of Pidgin and libpurple, and along the way I decided to write a plugin that would provide a feature that I was really missing from native Pidgin. There are often times where I would have my Pidgin open for days at a time, and would accumulate huge numbers of conversation tabs open, with many of those chat partners signed offline. I didn’t want to close all the tabs, only the offline buddies, and I didn’t see a way to do this in Pidgin. So I took a dive into the APIs for Pidgin and libpurple and came up with this little plugin that adds an item to the right click context menu of the tab bar in a conversation window that will close all offline buddies. Right now, I have only tested it working on Ubuntu 12.04.1 32 bit and 64 bit, but I assume it would work other places too. To install the plugin, first download it from:


Extract that folder, then open a terminal in that directory and run:

# ./install_ubuntu.sh

This should take care of setting up all the dependencies, compiling the plugin, and then installing it to the local user’s plugin directory.

If you care to browse the source code, its available in the downloaded zip file as well as in the github repository at: https://github.com/cemeyer2/pidgin-closeoffline