PB 0.5 is in my final testing. Just going to let it run a few hours before I post it on Monday. Adds station changing (finally) from menu, applescript or hotkeys. It’s actually a much larger change than it looks. There was a lot of under-the-covers restructuring while I got that working.
Next plans: either investigate how to masquerade as iTunes (so that stuff that works with iTunes will transparently work with PandoraBoy), or work on some eye-candy features (full-screen mode, floating semi-transparent windows, etc.)
Why is it when I want to test PandoraBoy with an album that has no artwork available, suddenly Pandora becomes so good at having every piece of artwork on every track for 7 different stations until I run out of hourly skips?
Well, at least I finally fixed that stupid “thumbs-up in the lower left of the Pandora window” bug that’s been driving me crazy for so long. Check for nil returns people!
I’m still trying to understand how Pandora manages skip tracking. I’m not planning on circumventing it, I just want to mark skipped tracks in the track listing (Cmd-T). Skips don’t seem to generate traffic back to the server or unique API events, so it seems that the client keeps track of skip counts. But it also seems persistent across Pandora restart, so I guess they’re storing it in Flash local storage. I swear they didn’t used to keep track of skips if you switched stations and then switched back, but then they also didn’t used to keep track of your place in the song when you switched stations. Curiouser and curiouser.
Have I mentioned recently how much I love Cocoa? Even when I hate Cocoa, I love working in it. And things that drive me nuts (like the lack of regexes) come along in due course (Leopard). I was listening to CocoaRadio today and there was a comment along these lines. Cocoa has been evolving for about 20 years now. Much of the core is carried over from NeXT. But rather than “showing its age” it keeps showing its wisdom, and those early guys thought it out well enough that Apple hasn’t had to start over again and again as Windows has with Win32 to MFC/WTL to .NET. For how unusual Objective-C is, it’s a constant rather than moving between C, C++, C#, and Java as the winds blow. (And the more I program in Objective-C, the more I enjoy it.)
Tonight I added a station-changing menu to PandoraBoy. There’s still a lot to add to make it really useful (hotkey support and Applescript at least), but the core’s there, and it wasn’t hard. It forced me to simplify a slight duplication in the object model (PandoraControl and Controller were doing almost exactly the same work so I’ve merged them). That cleaned up a lot of redundant code. Even after merging the two objects, Controller is under 400 lines of code, so I don’t think I need to worry about splitting Controller back up some other way.
More hacking on station lists tonight. So far it’s been as easy as I hoped, once I created a reliable way to watch all Pandora traffic (through NSURLProtocols). The station list comes back as an XML document, and I can copy that off into an easy array for later use. The only thing I need to work more on is QuickMix management, since those are magically pulled out of the main channel list, and I should probably do the same to avoid confusion.
I’ve talked often with folks about XML and how there are so many good ways to compress it quite effectively and it’s strange that XML developers have chosen not to do that. Rather, real XML winds up being insanely verbose and bloated on the wire. I hereby take back my earlier complaints. The fact that I can read XML by sniffing the traffic without having to apply any decoding (not even gunzip), and can recognize XML easily when I come across it, is one of the biggest boons to reverse engineering I’ve ever encountered. Long live human readable data formats!
I knew I’d run into this when I released PandoraBoy 0.4.0, and someone ran into Issue 17. Moving from MacOS 10.4.10 to 10.4.11 included a massive change to WebKit, and the 0.4 line was meant to address this. Unfortunately I no longer had a 10.4.10 box to test against, and so I figured that something would probably break. Hope against hope, I figured everyone would have upgraded by now.
Anyway, I will now undertake a series of “did this fix it” patches and we’ll see if we can get it working again. Hopefully the entire problem was my removal of decidePolicyForNewWindowAction: which never seems to be called in the new WebKit under Pandora (but I should have kept for completeness anyway). But it’s possible that the problem is deeper.
It’s been quite a while since I’ve updated the Rob Report, but I have some things to chat about on the technical front. Most of my work these days is on the Mac, and my main hobby project is PandoraBoy, which will probably dominate these blog posts for a while. It’s been a great project for teaching me how to deal with some interesting parts of Cocoa, while being small enough to keep my brain around.
My current project for PandoraBoy is getting control of station changing. I now have a set of proxy NSURLProtocols that I can use to eavesdrop on the Pandora traffic (rather than having to post requests like listStations twice). That’s how I grab album art. I’m using it to learn much more about how Pandora talks to its server, allowing me to provide more Mac-friendly ways to send those messages. I’ve demonstrated now that I can send launchStationFromId messages from Cocoa, so now I just need to collect the results of listStations so I have the IDs to send. Shouldn’t be hard now.
In the process, I discovered FireBug, which is just incredible. Using it, I understand Pandora’s code much better and am now mulling about what I could do with all this information. But my next project will probably be talking to Airport Express (after I fix a couple of new bugs in the 0.4 line). I’m pretty close to calling this thing 1.0….