iTunes is iAnnoying

Too bad the iPhone makes you get sucked into the world if iTunes – because it sucks.  I knew this going in, but it still isn’t fun when the limitations smack you in the face.

The limitation of which I speak is its inability to detect new files in its directories, automatically update its library database, and make it available for syncing and playing.  I spent a while fumbling around the UI looking for the option to turn it on, only to be ultimately disappointed by a few google searches. 

My initial plan was to take home movie clips (btw, MediaCoder is pretty handy..) and drop them into a directory managed by iTunes so they’d automatically get sent to the phone, but now I was going to have to add additional steps of manually adding the new videos each time they get created.  That’s just too much work and I’m too lazy.

I ran across an app or two that would do this updating for you, but instead decided to go a different route – creating a podcast that iTunes would auto-update and sync to the phone.  Tuesday night I whipped up an ASP.NET request handler (IHttpHandler) to generate feeds based on directory contents.  So now I’ve got the auto-updating capability I was initially looking for: after I create the video, I just drop it into a directory accessible by my webserver and iTunes will pick it up the next time it requests the feed.  As an added bonus, David now has a podcast for family and friends 🙂

Some more details on the code below the break.

So, the C#..

It’s just a pair of classes and some web.config entries.  First, the IHttpHandler: 

public class PodcastHandler : IHttpHandler {...}

This class’ ProcessRequest just takes the requested URL and pulls out which feed it should generate. Requests it’s configured (in web.config) to handle are of the form feedname.podcast. After it determines which feed to generate, it then looks up configuration values for that feed from the appSettings section of the web.config file. The values are named in the form “feedname.configvalue”.

So for my new feed, the appSettings section has entries like:

      <add key="test.mediaLocation" value="g:sharedpodcastvideos"/>
      <add key="test.extensions" value="mp4,m4v"/>
      <add key="test.title" value="My Test Podcast"/>
      <add key="test.description" value="Just a test!"/>
      <add key="test.publishDate" value="12/3/2008"/>
      <add key="test.mediaWebRoot" value=""/>

The PodcastHandler then just hands these values off to another class that gererates the required RSS xml.

The last thing needed is to tell the ASP.NET engine when to use this new IHttpHandler. That configuration is done by registering the handler in the website’s web.config like so:

        <add verb="*" path="*.podcast" type="Eji.Podcast.PodcastHandler,Eji.Podcast"/>

That tells ASP.NET to create an instance of my class and use it whenever a request comes in for something.podcast.

Right now the feed items are using the filenames as the title and don’t have a description – I suppose if I get bored I can pull this info from the metadata stuck in the media files. But for now, this is all I need.

One thought on “iTunes is iAnnoying

Comments are closed.