Again, this is public domain, feel free to hack away and improve it.
#!/usr/bin/env ruby
#
# This program will download the latest session JSON data
# from the WWDC website and turn it into an iCal
#
# Sorry about the cheezy HTML formatting; I am not a designer.
# If you'd like to contribute a better looking design, I'll
# incorporate it.
#
# Requires one of the following two gems to be installed:
#
# gem install json
# gem install json_pure
output = <<OUTPUT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
OUTPUT
r = open("http://developer.apple.com/wwdc/data/sessions.json").read
parsed = JSON.parse r
data = parsed["SessionsData"]
data.each do | oneSession |
upperTime = DateTime.parse(oneSession["time"][0]["upper"])
lowerTime = DateTime.parse(oneSession["time"][0]["lower"])
output << "BEGIN:VEVENT\n"
output << lowerTime.strftime("DTSTART;TZID=US/Pacific:%Y%m%dT%H%M%S\n");
output << upperTime.strftime("DTEND;TZID=US/Pacific:%Y%m%dT%H%M%S\n");
output << "DESCRIPTION:\n"
output << "LOCATION:\n"
output << "SUMMARY: ( )\n"
# output << "<TR>"
# output << "<TD>#{oneSession["id"]}</TD><TD>#{oneSession["title"].to_s}</TD><TD>#{oneSession["focus"].to_s}</TD><TD>#{oneSession["level"].to_s}</TD><TD>#{oneSession["type"].to_s}</TD><TD WIDTH = \"200\">Start: #{lowerTime.to_s} <BR/>End: #{upperTime.to_s}</TD><TD>#{oneSession["room"].to_s}</TD><TD>#{oneSession["description"].to_s}</TD></TR>\n"
#
output << "END:VEVENT\n"
end
output << "END:VCALENDAR"
File.open("sessions.ics", 'w') {|f| f.write(output) }
No comments:
Post a Comment