<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dan.thoughts &#187; amazon</title>
	<atom:link href="http://blog.sosedoff.com/tag/amazon/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sosedoff.com</link>
	<description>Web-development, PHP, Ruby, Sinatra, Merb, Rails, MySQL, SQLite, Web Services.</description>
	<lastBuildDate>Sat, 03 Jul 2010 05:46:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Amazon product images on your website</title>
		<link>http://blog.sosedoff.com/2010/06/15/using-amazon-product-images-on-your-website/</link>
		<comments>http://blog.sosedoff.com/2010/06/15/using-amazon-product-images-on-your-website/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 06:20:17 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[ecs]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[scaling]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=237</guid>
		<description><![CDATA[Amazon has an awesome image service. You can use their product images on your site, adjusting them for you needs. All you have to know &#8211; one image url of your product. Having that string will provide you an access to its dynamic image scaling service which i had to use recently. 
So, lets say [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon has an awesome image service. You can use their product images on your site, adjusting them for you needs. All you have to know &#8211; one image url of your product. Having that string will provide you an access to its dynamic image scaling service which i had to use recently. </p>
<p>So, lets say you have books on your website, but you dont have any good images for them. There is 2 ways to solve your problem: 1) download it from whatever place and resize 2) use amazon!</p>
<p>Here goes small overview.</p>
<p>Unfortunately, i didnt have any time to play with image service for different countries, but i assume that wont change that much.  Lets take a look on a regular image:</p>
<p>http://ecx.images-amazon.com/images/I/41ygBmdaIfL._SL500_SS100_.jpg</p>
<p>It has different parts:<br />
1) URL base: http://ecx.images-amazon.com/images/I/<br />
2) Image code: 41ygBmdaIfL<br />
3) Size format (surrounded by underscores): _SL500_SS100_<br />
4) Format: jpg/gif/png</p>
<p>Some words about image format. It can vary from square thumbnails to images with specific max width and height. For example: _SX100_ will produce image that 100 pixels wide, height will be calculated proportionally. SH100 will give opposite result, scaled by 100 pixels maximum height, SS100 &#8211; 100&#215;100 pixels thumbnail. And so on, you can find other similar crop codes while exploring amazon store on different pages, all you need is to take a look on image sources. </p>
<p>Now, we need to use this with Ruby:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/http'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">module</span> Amazon
  <span style="color:#008000; font-style:italic;"># parse amazon image url and get image code and extension</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">parse_image</span><span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
    result = url.<span style="color:#9900CC;">scan</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>^http:\<span style="color:#006600; font-weight:bold;">/</span>\<span style="color:#006600; font-weight:bold;">/</span>ecx.<span style="color:#9900CC;">images</span><span style="color:#006600; font-weight:bold;">-</span>amazon.<span style="color:#9900CC;">com</span>\<span style="color:#006600; font-weight:bold;">/</span>images\<span style="color:#006600; font-weight:bold;">/</span>I\<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>a<span style="color:#006600; font-weight:bold;">-</span>z0<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span>\<span style="color:#006600; font-weight:bold;">-</span>\<span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">1</span>,<span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>_.<span style="color:#006600; font-weight:bold;">&#40;</span>jpg<span style="color:#006600; font-weight:bold;">|</span>jpeg<span style="color:#006600; font-weight:bold;">|</span>gif<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span>i<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">unless</span> result.<span style="color:#0000FF; font-weight:bold;">nil</span>?
      <span style="color:#9966CC; font-weight:bold;">unless</span> result<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
        match = result.<span style="color:#9900CC;">first</span>
        <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#006600; font-weight:bold;">&#123;</span>:code <span style="color:#006600; font-weight:bold;">=&gt;</span> match.<span style="color:#9900CC;">first</span>.<span style="color:#9900CC;">to_s</span>, <span style="color:#ff3333; font-weight:bold;">:extension</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> match.<span style="color:#9900CC;">last</span>.<span style="color:#9900CC;">to_s</span><span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># make a new amazon image url based on code and size</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">make_image</span><span style="color:#006600; font-weight:bold;">&#40;</span>image, size<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#996600;">&quot;http://ecx.images-amazon.com/images/I/#{image[:code]}._#{size.upcase}.#{image[:extension]}&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># check if actual image exists</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">check_image</span><span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">begin</span>
      uri = <span style="color:#CC00FF; font-weight:bold;">URI</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
      req = <span style="color:#6666ff; font-weight:bold;">Net::HTTP::Get</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>uri.<span style="color:#9900CC;">path</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      res = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">start</span><span style="color:#006600; font-weight:bold;">&#40;</span>uri.<span style="color:#9900CC;">host</span>, uri.<span style="color:#9900CC;">port</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>http<span style="color:#006600; font-weight:bold;">|</span> http.<span style="color:#9900CC;">request</span><span style="color:#006600; font-weight:bold;">&#40;</span>req<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> res.<span style="color:#9900CC;">code</span> == <span style="color:#996600;">'200'</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> res.<span style="color:#9900CC;">content_length</span>.<span style="color:#9900CC;">to_i</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span>
    <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span>
      <span style="color:#0000FF; font-weight:bold;">false</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And usage:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">url = <span style="color:#996600;">'http://ecx.images-amazon.com/images/I/51O65dIoZCL._SX117_.jpg'</span>
info = Amazon.<span style="color:#9900CC;">parse_image</span><span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">unless</span> info.<span style="color:#0000FF; font-weight:bold;">nil</span>?
  new_url = Amazon.<span style="color:#9900CC;">make_image</span><span style="color:#006600; font-weight:bold;">&#40;</span>info, <span style="color:#996600;">'sx100'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> Amazon.<span style="color:#9900CC;">check_image</span><span style="color:#006600; font-weight:bold;">&#40;</span>new_url<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Cool! Resized image: #{new_url}&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Sorry, this image does not exist!&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">else</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Cant identify image!&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Some notes about the process. The only reason why method &#8220;check_image&#8221; uses GET method instead of HEAD is because if image cannot be generated or not found in amazon`s cache the response is still valid sometimes. I`ve checked it on 50k images and sometimes HEAD request indicates that response is valid while it not supposed to. Otherwise i would use HEAD.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2010/06/15/using-amazon-product-images-on-your-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple file uploader to Amazon S3 Service</title>
		<link>http://blog.sosedoff.com/2009/03/22/simple-file-uploader-to-amazon-s3-service/</link>
		<comments>http://blog.sosedoff.com/2009/03/22/simple-file-uploader-to-amazon-s3-service/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 04:59:18 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[s3]]></category>
		<category><![CDATA[simple]]></category>
		<category><![CDATA[uploader]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=115</guid>
		<description><![CDATA[For a long time i was thinking that Amazon`s Simple Storage Service (S3) is very complicated thing. But, it was before i tried it. Couple days ago, i got account to S3 and started exploring API`s and architecture. Now i see how stupid i was   It`s really easy to handle all operations with [...]]]></description>
			<content:encoded><![CDATA[<p>For a long time i was thinking that <a href="http://aws.amazon.com/s3/">Amazon`s Simple Storage Service (S3)</a> is very complicated thing. But, it was before i tried it. Couple days ago, i got account to S3 and started exploring API`s and architecture. Now i see how stupid i was <img src='http://blog.sosedoff.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  It`s really easy to handle all operations with files and buckets. Pricing also comfortable.</p>
<p>Welcome to cloud computing! <img src='http://blog.sosedoff.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I started using it with Ruby. Regular gem and docs can be found at <a href="http://amazon.rubyforge.org/">http://amazon.rubyforge.org/</a></p>
<p>So, the first useful tool i decided to created &#8211; simple uploader of local files to amazons server.<br />
First, we need to create bucket and make it public:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Bucket.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'NAME_HERE'</span>,:access <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:public_read</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Here`s the client ruby script:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'aws/s3'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">AWS::S3</span>
&nbsp;
<span style="color:#ff6633; font-weight:bold;">$s3_bucket</span> = <span style="color:#996600;">&quot;BUCKET_NAME&quot;</span>
<span style="color:#ff6633; font-weight:bold;">$s3_key</span> = <span style="color:#996600;">&quot;API_KEY&quot;</span>
<span style="color:#ff6633; font-weight:bold;">$s3_secret</span> = <span style="color:#996600;">&quot;API_SECRET&quot;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> s3_store<span style="color:#006600; font-weight:bold;">&#40;</span>localfile<span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>localfile<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;</span>amp;<span style="color:#006600; font-weight:bold;">&amp;</span>amp; <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">readable</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>localfile<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Uploading file [#{localfile}]. Size: #{File.size(localfile)} bytes.&quot;</span>
		name = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">basename</span><span style="color:#006600; font-weight:bold;">&#40;</span>localfile<span style="color:#006600; font-weight:bold;">&#41;</span>
		Base.<span style="color:#9900CC;">establish_connection</span>!<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:access_key_id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff6633; font-weight:bold;">$s3_key</span>, <span style="color:#ff3333; font-weight:bold;">:secret_access_key</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff6633; font-weight:bold;">$s3_secret</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		S3Object.<span style="color:#9900CC;">store</span><span style="color:#006600; font-weight:bold;">&#40;</span>name, <span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>localfile<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff6633; font-weight:bold;">$s3_bucket</span>, <span style="color:#ff3333; font-weight:bold;">:access</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:public_read</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Download link: http://s3.amazonaws.com/#{$s3_bucket}/#{name}&quot;</span>
	<span style="color:#9966CC; font-weight:bold;">else</span>
		<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;File not exists or not accessible. Please check file and try again!&quot;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
path = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#9966CC; font-weight:bold;">if</span> !path
	<span style="color:#996600;">&quot;Please specify the file to upload.&quot;</span>
<span style="color:#9966CC; font-weight:bold;">else</span>
	s3_store<span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>Download script: </strong> <a href="http://files.sosedoff.com/036cfedd/">http://files.sosedoff.com/036cfedd/</a></p>
<p>BTW, I found cool firefox add-on to manage S3 objects/files. It`s pretty easy.<br />
Link to extension &#8211; <a href="http://www.s3fox.net">http://www.s3fox.net</a><br />
Screenshot:<br />
<img class="alignnone" title="S3 Firefox Extension" src="http://www.omniuploader.com/s3fox/features/s3fox_main.gif" alt="" width="500" height="309" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2009/03/22/simple-file-uploader-to-amazon-s3-service/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fetching album covers from Amazon Web Service</title>
		<link>http://blog.sosedoff.com/2009/02/15/fetching-album-covers-from-amazon-web-service/</link>
		<comments>http://blog.sosedoff.com/2009/02/15/fetching-album-covers-from-amazon-web-service/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 05:05:29 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[covers]]></category>
		<category><![CDATA[fetch]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=66</guid>
		<description><![CDATA[On my small project i was looking for web service to get media covers from. I found that i can use Amazon Web Services API. The documentation for this ECommerce Service is pretty old, but it still works.
More detailed information about API you can find here

#!/usr/bin/ruby
&#160;
require 'rubygems'
require 'net/http'
require 'cgi'
require 'xmlsimple'
&#160;
$amazon_key = &#34;12DR2PGAQT303YTEWP02&#34; # NOT MY [...]]]></description>
			<content:encoded><![CDATA[<p>On my small project i was looking for web service to get media covers from. I found that i can use Amazon Web Services API. The documentation for this ECommerce Service is pretty old, but it still works.<br />
More detailed information about API you can find <a href="http://docs.amazonwebservices.com/AWSEcommerceService/2005-02-23/">here</a></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/http'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'xmlsimple'</span>
&nbsp;
<span style="color:#ff6633; font-weight:bold;">$amazon_key</span> = <span style="color:#996600;">&quot;12DR2PGAQT303YTEWP02&quot;</span> <span style="color:#008000; font-style:italic;"># NOT MY KEY (FOUND ON INTERNET)</span>
<span style="color:#ff6633; font-weight:bold;">$amazon_host</span> = <span style="color:#996600;">&quot;webservices.amazon.com&quot;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> fetch_cover<span style="color:#006600; font-weight:bold;">&#40;</span>artist, album<span style="color:#006600; font-weight:bold;">&#41;</span>
	artist = <span style="color:#CC00FF; font-weight:bold;">CGI</span>.<span style="color:#9900CC;">escape</span><span style="color:#006600; font-weight:bold;">&#40;</span>artist<span style="color:#006600; font-weight:bold;">&#41;</span>
	album = <span style="color:#CC00FF; font-weight:bold;">CGI</span>.<span style="color:#9900CC;">escape</span><span style="color:#006600; font-weight:bold;">&#40;</span>album<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
	path = <span style="color:#996600;">&quot;/onca/xml?Service=AWSECommerceService&amp;AWSAccessKeyId=#{$amazon_key}&amp;Operation=ItemSearch&amp;SearchIndex=Music&amp;Artist=#{artist}&amp;ResponseGroup=Images&amp;Keywords=#{album}&quot;</span>
	data = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">get</span><span style="color:#006600; font-weight:bold;">&#40;</span>$amazon_host, path<span style="color:#006600; font-weight:bold;">&#41;</span>
	xml = <span style="color:#CC00FF; font-weight:bold;">XmlSimple</span>.<span style="color:#9900CC;">xml_in</span><span style="color:#006600; font-weight:bold;">&#40;</span>data<span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#9966CC; font-weight:bold;">if</span> xml<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Items'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'TotalResults'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">to_i</span> <span style="color:#9966CC; font-weight:bold;">then</span>
		cover = <span style="color:#006600; font-weight:bold;">&#123;</span>
			<span style="color:#ff3333; font-weight:bold;">:small</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> xml<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Items'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Item'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'SmallImage'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'URL'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
			<span style="color:#ff3333; font-weight:bold;">:medium</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> xml<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Items'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Item'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'MediumImage'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'URL'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
			<span style="color:#ff3333; font-weight:bold;">:big</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> xml<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Items'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Item'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'LargeImage'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'URL'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
		<span style="color:#006600; font-weight:bold;">&#125;</span>
		<span style="color:#0000FF; font-weight:bold;">return</span> cover
	<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">nil</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>So, after execution of this function you will get array with 3 different images (small, medium, big).<br />
I use XML-Simple gem for ruby. Can be installed this way</p>
<pre>sudo gem install xml-simple</pre>
<p>That`s it. <a href="http://files.sosedoff.com/bace6a22/">Download script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2009/02/15/fetching-album-covers-from-amazon-web-service/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
