{"id":3017,"date":"2014-01-19T23:07:30","date_gmt":"2014-01-19T23:07:30","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=3017"},"modified":"2014-01-19T23:12:49","modified_gmt":"2014-01-19T23:12:49","slug":"creating-an-icalendar-from-online-timetables","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=3017","title":{"rendered":"Creating an iCalendar from online timetables"},"content":{"rendered":"<p>I&#8217;m a member of my local swimming pool, <a href=\"http:\/\/www.dcleisurecentres.co.uk\/centres\/fleming-park-leisure-centre\">Fleming Park<\/a>. I&#8217;m trying to swim a lot at the moment (as it&#8217;s <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=2911\">a big help for my back<\/a>). <\/p>\n<p><a href=\"http:\/\/www.dcleisurecentres.co.uk\/centres\/fleming-park-leisure-centre\/timetables\/swim\"><img decoding=\"async\" src=\"http:\/\/dalelane.co.uk\/blog\/post-images\/140119-flemingpark.jpg\" border=0 align=\"left\" hspace=5 vspace=5\/><\/a>I don&#8217;t have a regular schedule, I just try and squeeze in time for a swim any time I can spare. This means I&#8217;ve not learned the pool&#8217;s schedule and frequently have to check their website to find when the pool is available. <\/p>\n<p>I&#8217;m checking it so frequently that it&#8217;s one of my Most Visited thumbnails in Chrome. <\/p>\n<p>This isn&#8217;t efficient, particularly as it&#8217;s normally on my phone making me switch between the browser and Calendar apps. It&#8217;d be quicker and easier if I had the timetable in my calendar alongside my appointments, so I could easily see when I&#8217;m free and the pool is open. <\/p>\n<p>The leisure centre doesn&#8217;t provide a feed so I can subscribe and add their schedule to my calendar. <\/p>\n<p>So I made my own.<\/p>\n<p><strong><a href=\"http:\/\/dalelane.co.uk\/files\/dcleisuretimetables\/swimflemingpark.ics\">dalelane.co.uk\/&#8230;\/swimflemingpark.ics<\/a><\/strong><\/p>\n<p>If you use the Fleming Park pool, import <a href=\"http:\/\/dalelane.co.uk\/files\/dcleisuretimetables\/swimflemingpark.ics\">this<\/a> in your Calendar app (or <a href=\"https:\/\/support.google.com\/calendar\/answer\/37100\">subscribe to it from Google Calendar<\/a>) and the next week&#8217;s pool timetable will be kept up to date in your calendar. <\/p>\n<p><!--more-->I&#8217;ve done it with a quick bit of Python hacking. I download the HTML source for the next seven days&#8217; timetables, and parse each of them using <a href=\"http:\/\/www.crummy.com\/software\/BeautifulSoup\/\">BeautifulSoup<\/a>. I pick out the swimming session info, and generate an ics file for them using <a href=\"http:\/\/icalendar.readthedocs.org\/en\/latest\/\">iCalendar for Python<\/a>. <\/p>\n<p>I&#8217;ve put it on <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=1228\">my home media server<\/a>, and set up a cron job to run it every twenty-four hours, with a shell script to upload it to dalelane.co.uk\/files. <\/p>\n<p>It&#8217;s a quick hack, so it&#8217;s specific to Fleming Park. Although, at first glance at <a href=\"http:\/\/www.dcleisurecentres.co.uk\/centres\/river-park-leisure-centre\/timetables\">another similar-looking local pool website<\/a>, I think it&#8217;ll probably work on other DC Leisure Centre websites. <\/p>\n<p>The <a href=\"https:\/\/gist.github.com\/dalelane\/8512102\">source for the script is on github<\/a>. <\/p>\n<p><script src=\"https:\/\/gist.github.com\/dalelane\/8512102.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a member of my local swimming pool, Fleming Park. I&#8217;m trying to swim a lot at the moment (as it&#8217;s a big help for my back). I don&#8217;t have a regular schedule, I just try and squeeze in time for a swim any time I can spare. This means I&#8217;ve not learned the pool&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[495,558,212],"class_list":["post-3017","post","type-post","status-publish","format-standard","hentry","category-code","tag-calendar","tag-ics","tag-python"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3017"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3017\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}