Well, my week long vacation is slowly slipping away, and it appears that I’ll do relatively little programming during the 11 consecutive days that I have off. Still, I’ve worked my way through a couple of niggly tasks that have been nagging me for a long time, so my time isn’t entirely wasted.
Today I spent about half an hour investigating the possibility of trying to write my own version of Adam Curry’s iBlogger script. The idea is to check RSS feeds for enclosures (which are a particular chunk of XML used to indicate large media payloads), download them automatically, and then automatically add them to your iTunes playlist so that the next time you sync your trusty white companion, you get all the downloaded mp3 files available for your next convenient listening opportunity. That doesn’t sound too hard, and in fact, the first two bits are remarkably easy. In just a couple of minutes, I wrote an eight line Python script that used Mark Pilgrim’s feedparser library to open Adam’s feed, find all the enclosures, then use wget to grab the named mp3 file. It wouldn’t be hard to not use wget: I just like it’s automatic bandwidth limiting capability, which keeps downloads from swamping my wimpy cable modem.
As I said, a piece of cake.
Well, except for getting it to talk to iTunes. If I was on a Macintosh, it would be relatively simple to use Applescript to do it, but I use Windows XP on my laptop and FreeBSD and Linux on my two desktop machines. I normally synch my iPod using iTunes on my laptop, but frankly, I wasn’t averse to trying other ideas, so I downloaded gnupod, a set of perl scripts that can talk to my iPod and installed them on fishtank, my trusty FreeBSD box. I then plugged in my iPod and….
Promptly got screen fulls of fwohci: phy intr messages from FreeBSD. Frown.
Then, I remembered that I had never actually tried hooking a firewire device to this box, and I had some difficulty installing the confusing header blocks to the front mounted panel I added to my box. Instead of supplying a nice solid 2×6 block header, they had 11 separate little pins that each had to be wired to the right location. Bleh. I didn’t feel like sorting this out, so I found the normal rear panel header, shut down my computer, disconnected the front panel, hooked up the rear panels and thirty seconds later rebooted.
Voila! The machine responded with the expected:
da0 at sbp0 bus 0 target 0 lun 0 da0:
Removable Simplified Direct Access SCSI-2 device da0: 50.000MB/s transfers, Tagged Queueing Enabled da0: 19073MB (39063024 512 byte sectors: 255H 63S/T 2431C)
A simple addition to
/etc/fstab, and I mounted the disk and could begin to search around. I could even use
mplayer to play some of the audio files that I found nestled in the subdirectories.
Okay, so next I installed
gnupod and followed their instructions. But this too failed. When I attempted to run gnupod_INIT.pl, it complained about a compilation error. Harumph. Then I remembered that the version of perl installed in
/usr/bin by FreeBSD is actually an early version of perl5. The version installed by the ports is more recent. Could this be the problem? A bit of scurrying around, and I managed to get the port installed and set it as the default.
And voila! It worked. I could use the
gnupod_addsong.pl to add .mp3 files, and then run
mktunes.pl to update the database, unmounted the disk, used
camcontrol eject da0 and I had a bunch of new mp3 files on my iPod.
This isn’t probably the ideal solution for anyone, even me, but it is a solution that I can understand. I’ve also downloaded Apple’s SDK information about using COM objects to program iTunes, but I must admit that I’ve never done anything like that before, so it’s probably more work than I would like at the moment. An afternoon’s work with Python and gnupod will probably get me to a fairly painless solution. I should have some time tomorrow to goof around. Stay tuned.