Under The Microscope

PyAMF Is Awesome

The recent release of Pulsar 1.5.6 added support for XM Radio’s new Canadian “XM online+” service. While Canadian XM users previously used the normal “XM Online Radio” service, XM/Canada appears to have gone out on their own and created a custom player.

When this new XM online+ first appeared, back in December, we were rather alarmed by it. Previous SIRIUS and XM players were mostly HTML/JavaScript-based, but this new service is entirely Flash-based. Concerns about iPod Touch/iPhone/iPad support aside, this meant our typical methods of web scraping would not work. We needed an entirely new approach to get it working in Pulsar.

Upon further investigation, we saw that the site was using Adobe’s RPC system known as Action Message Format (AMF) for transferring data (such as station info, track titles, and more) between the Flash client and XM’s servers. This was discouraging as well. Rather than having easy access to data in simple plain text or JSON, getting it out of AMF would entail spending weeks implementing and debugging an AMF decoder/encoder in Objective-C.

Two things came to our aide though. The first is that although Pulsar has a user interface implemented in Cocoa/Objective-C, the backend that talks to SIRIUS and XM’s servers is implemented entirely in Python. The second is a lovely little Python library called PyAMF.

As you might gather from the name, PyAMF implements full support for Action Message Format in Python, including RPC. And thus getting the necessary data from XM online+, a task we thought would take us weeks to do, was up and running in under a day. Adding complete support for XM Online+ took us under a week in total, from start to finish.

We’d like to give our thanks to the PyAMF team for making their wonderful little library available. We’ve made a small donation, of 0×100 hex bucks (that’s $256 USD) to PyAMF, and we’d like to publicize them as well. For anyone that ever runs into an AMF problem like ours, we can say look no further than PyAMF.

One Response to “PyAMF Is Awesome”

  1. Aaron McQuinn says:

    Thank you! I’m Canadian and very much appreciate that Pulsar supports the new online-only subscription.


Leave a Reply

You must be logged in to post a comment.

Our Software