There are a lot of sites that provide little Flash audio widgets that allow you to listen to a tune but make it difficult to download. MySpace, for example, has a player that a lot of bands use to promote their music. Songs are downloaded to the player in normal MP3 format, but each time you load the player it is given a special token that it can use to access the audio. This token is passed back to the server in the query string by flash when a file is requested, which authenticates the download. Once the download has completed, the token is invalid for future downloads. Essentially, this protects people from figuring out the song URL and then hotlinking to it from another site.

What it doesn’t do is protect you from downloading and saving a copy of the MP3 to your own machine. The Flash widget makes finding the URL a bit of an annoyance, but it’s easy enough to discover that you can initiate your own download before the player has completed. Here’s how:

  1. Wait for the page to finish loading and then play the song you want to download.
  2. Open up the Activity Monitor window in Safari, or use the network activity monitor in FireBug for Firefox.
  3. You’ll be able to quickly find the MP3 url. It’s the one with the heinously long query string, probably a few MB in size, and the only thing still downloading.
  4. Double click the URL to open it in a new window.

At this point, you have the song URL in your browser’s address bar and the Flash player is still downloading the file. Depending on what browser you are using, opening the MP3 may have started downloading the file to your download folder. If that’s the case, you’re done!

Safari will try to play the MP3 inside the browser and doesn’t allow you to save, though. That’s okay—we’ll use the command line instead. Just cut the URL from your address bar, hop over to a Terminal window, and type in the following:

curl -b nada 'http://paste_long_url_here' >out.mp3

Just make sure to put the single quotes around the URL that you’ve copied. If you execute this before the Flash widget’s download has completed, curl will begin downloading the audio file and dumping it into out.mp3. If you were too slow, you’ll get a 404 error. You’ll have to replay the file, get the new URL, and try again. It usually takes a half minute for the file to finish streaming in, so you shouldn’t have trouble getting this to work.