Introducing my ijf_ical.pl script

Tags:

This is the first of a series of posts I want to write about some of the Perl projects I have written or am writing.

Introduction

Today I want to introduce ijf_ical; which is a Perl script to produce a iCal file of all the Judo events on the International Judo Federation (IJF) calendar. This allows me to subscribe to the file and have all the IJF events in my calendar. The data is sourced from the IJF's data so is kept accurate as event dates change.

Overview

The code is a messy 104 lines ( https://github.com/lancew/ijf_ical/blob/master/ijf_ical.pl ), which does the following:

  • Get the JSON competition information from the IJF
  • Create an iCal event for each competition
  • Geocode the competition city and country and add the Lat/Long to the iCal event
  • Print the complete list

Details

I use Carton to manage the module dependencies. Specifically for this project I use:

The code itself is pretty simple; it makes a GET request to get all the events in JSON format

It then loops around each competition creating an iCal event from the data, a call is made to the OpenStreetMap Nominatim API via Geo::Coder::OSM and the latitude and longitude added to the event.

Then the iCal event is pushed into an array

Once all the events have been looped through; it prints out the ical file.

Use

Running the script is as simple as carton exec perl ijf_ical.pl > ijf.ics. I run this locally in the repo and actually commit the ijf.ics file to the repo. This means I can subscribe to https://raw.githubusercontent.com/lancew/ijf_ical/master/ijf.ics in my calendar app and I have all the IJF Judo competitions on my phone/computer.

Todo

Ahem... some tests would be good; and automating the build and running daily/weekly perhaps?