Today, like most Fall Sundayís, is a great day to watch Football. It was fun watching San Fransisco play, but I often hack around on the computer during games. Fortunately there is plenty of time between commercials and time-outs to work on code. I wondered how hard it would be to pull football scores into a dynamic usebar. Surprisingly, it wasnít as hard as I thought it would be.
First off, I had to find an API. I ran across this Accidental APIs: NFL edition article that linked to some open JSON API. I decided which API would fit the bill and started to program. Since I use Perl, I updated my CPAN library with the latest version of JSON routines and parsed out the games, progress, and scores. After figuring out some image libraries to pull from, it was only a matter of updating my scripts to display the information as a animated GIF. I did have to tweak my libraries a bit to display two images. I think the end results came out better than expected.
Put in image or BBCODE tag: https://www.reids4fun.com/ub/football.gif
I do need to put some effort into a better background image. I did accomplished my goal of displaying the scores. That is all that matters, for now.
Although the API I used still responds, it doesnít update for 2018. Doing a little digging, I found the latest scores are now in a new JSON feed. As such, Iíve substituted and updated my football signature. The cool thing is the new API has more details, so Iíve tweaked the text to leverage some of the newer features.
First off, the teams now display their nicknames instead of abbreviations. I also star the winning score to make it more obvious. I now only display the time left during a quarter. I needed to do some parsing to get the correct day to display. But otherwise, the user bar looks as before.