Football Fixtures Mini Project

While on the look out for a little coding project I found myself getting frustrated at scrolling through livescore to find the upcoming football matches that interested me. Sure, I could choose my favourite teams and favourite fixtures so they appear at the top but I wanted to build a fully customisable, auto-generating list of fixtures. At the very least it was a good excuse to write some perl and update my website.

I quickly stumbled upon football API which gives users a generous free 100 calls a day with all the football info you could ever want. A few days later and a number of hours trying to correctly access my array/hash references and I finally got my fixture page running.

The first stage in the process is the config file. This file contains the information about all the fixtures that I want to see on my fixtures page. Note, the API gives unique id's for each team and for each season of each league. The current options are

daysOfGames
Number of days of fixtures to display
Team
Get all fixtures from a team id
FullLeague
Get all fixtures from a league id
League
Get fixtures from a league id with a number of options. "Top" gets all fixtures where both teams are above the specified position. "Teams" specifies which teams playing each other should get picked. Useful for derbies etc. "Round" gets all fixtures from a given round.

This config file is read by the perl script GetFixtures which then makes the necessary API calls. The script chooses the correct fixtures returned from the API calls and stores them in an array called fixtures which is then sorted by date. This array is then saved as a json file called fixtures. The fixtures are then displayed using some simple javascript while the perl script is set to run daily as a cron job to keep fixtures up to date.

You can see my fixtures page at dcgmackenzie.uk/Fixtures

And just like that, I'll be up to date with all of Scotland's games in the Euro's next summer. Though that won't stop me filling out my wallchart as Scotland march to glory...