OK, let's see how this goes...
If all goes well there should be a attachment containing a Calibre plugin with this functionality. Hopefully this makes a few bits and pieces like finding the ASIN easier (assuming I got it right!)
The plugin is just a port to Python of the logic from shinew's original script - I haven't really done anything clever on top of that. The structure of the plugin is taken from the APNX Generator.
Please consider it alpha software.