I wrote this script so that I could check on my favorite NFL team's scores with one glance without having to load a web page or use a widget. This script is intended for use with geektool and is unfortunately not very fancy. I am a novice programer so any suggestions would be helpful as well as anyone who wants to make this script better. I only ask that you share it with me so that I can learn too. The included geeklet has the code directly inside of it so that you won't have to download anything else or use any links, however I have included the code so that you may use it however you see fit.
Simply place your favorite teams in the list at the beginning of this script and they will show up on your desktop.
******* UPDATE *********
9-1-2011 Fixed code to take halftime into account during a live game. I also added better quarter formatting as well as the time of the next game (if the team is not playing live.
******* UPDATE *********
In the comments below I have included a version of this code that displays all of the NFL scores instead of selecting which teams to display.
#!/bin/bash
#This script was written on August 27, 2011 by Kyle R. Jones (kr.jones@me.com)
#Place any number of teams into the team list. This list is then parsed from "http://www.nfl.com/liveupdate/scorestrip/ss.xml"
#for the current score. My intended goal is to use this with geektool.
team=(DAL DEN IND PHI NYG WAS)
for i in ${team[@]}; do
home_city=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.*h="\([^"]*\)".*/\1/'`
visiting_city=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.*v="\([^"]*\)".*/\1/'`
home_team=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.*hnn="\([^"]*\)".*/\1/'`
visiting_team=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.*vnn="\([^"]*\)".*/\1/'`
first=`echo ${home_team} | sed 's/\(.\).*/\1/'`
last=`echo ${home_team} | sed 's/.\(.*\)/\1/'`
upper=`echo ${first} | tr '[a-z]' '[A-Z]'`
home_team="$upper$last"
first=`echo ${visiting_team} | sed 's/\(.\).*/\1/'`
last=`echo ${visiting_team} | sed 's/.\(.*\)/\1/'`
upper=`echo ${first} | tr '[a-z]' '[A-Z]'`
visiting_team="$upper$last"
home_score=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.*hs="\([^"]*\)".*/\1/'`
visiting_score=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.*vs="\([^"]*\)".*/\1/'`
quarter=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.*q="\([^"]*\)".*/\1/'`
time_left=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.*k="\([^"]*\)".*/\1/'`
day=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.*d="\([^"]*\)".*/\1/'`
time=`curl -s http://www.nfl.com/liveupdate/scorestrip/ss.xml | grep ${i} | sed -e 's/.* t="\([^"]*\)".*/\1/'`
if [ $quarter = "F" ]; then
echo ${visiting_city} ${visiting_team} ${visiting_score} ${home_city} ${home_team} ${home_score} FINAL
elif [ $quarter = "P" ]; then
echo ${visiting_city} ${visiting_team} at ${home_city} ${home_team} on $day at $time Eastern
elif [ $quarter = "H" ]; then
echo ${visiting_city} ${visiting_team} ${visiting_score} ${home_city} ${home_team} ${home_score} HALFTIME
else
if [ $quarter = "1" ]; then
echo ${visiting_city} ${visiting_team} ${visiting_score} ${home_city} ${home_team} ${home_score} with ${time_left} in the ${quarter}st
elif [ $quarter = "2" ]; then
echo ${visiting_city} ${visiting_team} ${visiting_score} ${home_city} ${home_team} ${home_score} with ${time_left} in the ${quarter}nd
elif [ $quarter = "3" ]; then
echo ${visiting_city} ${visiting_team} ${visiting_score} ${home_city} ${home_team} ${home_score} with ${time_left} in the ${quarter}rd
else
echo ${visiting_city} ${visiting_team} ${visiting_score} ${home_city} ${home_team} ${home_score} with ${time_left} in the ${quarter}th
fi
fi
done