donkirkby

Monday, June 26, 2006

Television Listings in Ruby

For years, I've been poking at the idea of building a program that retrieves TV listings from the web and generates a personalized TV guide for me. For example, it would highlight shows that I like and just not display shows that I hate. When zap2it published a web service, I knew the time had come. I've played with it a bit using .NET and java clients, but now I'm using this project as an excuse to try out the ruby language.
I'd heard that Ruby is a neat little scripting language that makes programming fun. I decided to try it out on this project. It actually is pretty fun, but I'm not sure I'd want to lead a team of programmers on a Ruby project. You still need to be a bit of a hacker to figure out how to use it. Some of the API documentation is pretty slim, so you need to dig into the source code to see what you're supposed to do.
The first version of RubyTubyTeeVee is now working and up on source forge.

What's Next?

I have lots more features I'd like to add, but I think the first thing I'll do is look at moving it from a desktop application to a Ruby on Rails web application.

References

Here are the most useful references I found while working on this project.
  • Ruby home page - the centre of the Ruby universe.
  • Programming Ruby - A good introductory book that's available online.
  • Core API and Standard libraries - The most useful API documentation I've found.
  • Ruby installer for Windows - I'll be developing on the Windows platform, so this makes an easy starting point. If that link breaks, try the RubyInstaller home page.
  • FX Ruby - a GUI framework for Ruby. Seems to be included in the distribution. Check out the examples, particularly the raabrowser.
  • Printing - a sample that shows how to print from a Ruby app. Looks like the FXDCPrint and FXPrintDialog classes are a cleaner way to accomplish it, but they might not be finished yet. There's a code snippet that seems to do something similar by calling the Win32 API directly. I'm going to try Ruby RTF next. If that doesn't work, maybe these Ruby RTF Tools will.
  • REXML - a module for accessing XML from Ruby. Check out the tutorial or find more details in the library API. Because I'm processing large XML files, I decided to use an event model instead of parsing the whole thing into a Document Object Model (DOM). The StreamListener class shows the methods you need to implement for a listener. NOTE: the documentation for tag_start is incorrect: attrs is a Hash, not an array of arrays. There's an example of how to use your listener in the tutorial.
  • strftime specs - They're actually on the Time class instead of the Date class. Maybe it's one of those strange mixin things that I don't quite understand yet.
  • HTTP library documentation may help me make the request from the zap2it web service. This presentation might be helpful, or even this web service tutorial, although it might be outdated.
  • Zap2it web service specs. I think this requires a login.
  • Ruby web service client example.
  • Digest authentication is a big pain, but zap2it requires it. I found a ruby snippet that seems to generate the header for you, and a general description of digest authentication. Wow, was that a pain! The snippet didn't quite work for me, but I used the internet wayback machine to find the source code for the Java libraries that were handling the authentication in zap2it's java sample. I compared that to the Ruby snippet and found that the Ruby snippet was missing the algorithm and opaque fields, and it had hard coded the GET method so that POST requests would always fail. But now I have a Ruby class that sucessfully requests TV listings!

1 Comments:

At 12:21 am , Blogger seo company in mumbai said...

The blog is quite resourceful, however a touch of the professionals can diversity it even further. Our experts promise a fine quality all assignment The best experts in the business are here to take care of your academic needs.
students can receive online academic support.
Ruby assignment help

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home