Download Amazon MP3s in Terminal with clamz

Sponsored Links

Download Amazon MP3s in Terminal with clamz

If you've ever wanted to download Amazon MP3s via Terminal or over ssh, or ever found yourself unable to use the "Amazon MP3" then I have good news for you: there is another way.

The problem

Amazon's MP3 Store annoys me to no end. I love the deals that they occasionally offer, but in order to download the files, you have to download the Amazon MP3 Downloader. Inside that dmg file is an installer application that doesn't use the normal .pkg format.

The special installer failed to install the application on my Mac. I managed to install it manually (as well as the plugin that needs to be installed to "/Library/Internet Plug-Ins/"), but then the application kept crashing after each song.

So, to recap, Amazon doesn't use the standard package installer, and their installer failed to work; and they don't use normal downloads, and their non-standard downloader failed to work. This is why you should stick to standards -- they've been better tested for a lot longer than your "roll your own" solution. Stop reinventing the wheel.

The ".amz" file that you download from Amazon is an XML file which includes a download URL, but you can't access that URL to download the music directly. I was all ready to start sniffing TCP headers and try to figure out what special headers the Amazon MP3 uses, when the same thought occurred to me: "Don't reinvent the wheel."

The solution

I was able to find the solution on Google code, specifically at which is described as "is a little command-line program to download MP3 files from's music store."

Side note: I needed to install 'libgcrypt' in order to get clamz to build, which I did using Homebrew simply by typing brew install libgcrypt (assuming you already have brew and Xcode installed). The clamz page also mentions libcurl and libexpat, but those were already installed on my Mac.

Once I had the necessary libraries installed, installation of clamz was as simple as the instructions on its homepage:

Then I just had to get a "fresh" .amz file from Amazon. To do that, I went to the Amazon Cloud Player, clicked the checkbox at the top to select all my music (see #1 below) and then clicked "Download" (see #2 below):

Note that if you have more songs than will fit on one page, you may have to do this repeatedly for each "page". I only have 230 songs in my Amazon Cloud Player.

That downloaded new ".amz" file on my computer called "Amazon-MP3-1321140421.amz" (yours will be named something similar but different). Then I ran this command simple command:

   clamz --output-dir=~/Music/ ~/Downloads/Amazon-MP3-1321140421.amz 

and watched with sheer delight as clamz downloaded all of my Amazon music files. I accidentally closed my MacBook Air before it was finished, but was able to resume the download simply by adding the --resume flag:

   clamz --resume --output-dir=~/Music/ ~/Downloads/Amazon-MP3-1321140421.amz 

When it finishes, you can delete the .amz file, as the links it contains will expire anyway. You can always download another one later.

Thanks, Internet

This simply would not have been possible without the help of the open source community, both the developer behind clamz (Benjamin Moody) and the awesome folks behind Homebrew.

After I finished using clamz I also found pymazon, but I'm not sure if that works on Mac.

Since I criticized Amazon's non-standard downloader, someone might say "Well, iTunes is a non-standard downloader, too!" That's a valid point. If I had been trying to download from iTunes and it failed to work, I would not have been so fortunate to find an open source solution.

All products recommended by Engadget are selected by our editorial team, independent of our parent company. Some of our stories include affiliate links. If you buy something through one of these links, we may earn an affiliate commission.
Popular on Engadget