Requirements

Python 2.7 for standalone use or Python 2.4 or newer for library use

One of PyCrypto (fast) or pyDes (slow, but pure Python so easier to deploy) for encrypted AMZ handling

lxml for parsing the XML

These are packaged in Ubuntu as python-lxml and python-crypto, and should be available in most Linux distros.

Usage

Basic standalone usage to download all tracks in a particular file: ./pyamz.py AmazonMP3-1234567890.amz

Useful options: -w to use external wget to download (helpful if you have a rubbish internet connection); -n filepath to specify the output file format (use field specifiers such as {artist}); -h for usage help.

Library usage: pyamz.decrypt(amz_contents) returns the decrypted XML. pyamz.parse(xml) returns a list of dictionaries holding information on the tracks specified in the xml.