Wednesday, May 27, 2009

WWDC Session Times

Okay, the session times have not been officially released for WWDC, but the underlying data used for the sessions website contains time and room data. Of course, since this hasn't been released, it's completely unofficial and likely to change, but for those who have been asking for WWDC session times, I give you... not the session times, but a script that will fetch the latest data and format it into a HTML table for you.

It's a ruby script, so it should run on any stock OS X machine. This is public domain code, do with it what you will. If you improve it, I'd love a copy of your version.

#!/usr/bin/env ruby
#
# This program will download the latest session JSON data
# from the WWDC website and will parse it into a plain
# HTML table so it can be viewed.
#
# 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
require 'rubygems'
require 'net/http'
require 'open-uri'
require 'json'


output = ""
output << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n\"http://www.w3.org/TR/html4/loose.dtd\">\n<HTML><head>\n\t<title>WWDC Session Times</title>\n</HEAD><body>"
output << "<TABLE WIDTH=\"100%\" BORDER=\"1\"><TR><TH>ID</TH><TH>Title</TH><TH>Focus</TH><TH>Level</th><TH>Type</TH><TH>Time</TH><TH>Room</TH><TH>Description</TR>\n"

r = open("http://developer.apple.com/wwdc/data/sessions.json").read

parsed = JSON.parse r
data = parsed["SessionsData"]

data.each do | oneSession |


lowerTime = oneSession["time"][0]["lower"]
upperTime = oneSession["time"][0]["upper"]


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"

end

output << "</table></body>"
File.open("sessions.html", 'w') {|f| f.write(output) }
exec 'open sessions.html'

No comments:

Post a Comment