Skip to content

Instantly share code, notes, and snippets.

@zerokarmaleft
Created April 21, 2011 19:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerokarmaleft/935336 to your computer and use it in GitHub Desktop.
Save zerokarmaleft/935336 to your computer and use it in GitHub Desktop.
Retrieving album cover art from AWS with MacRuby and Sucker
framework 'Cocoa'
require 'rubygems'
require 'sucker'
application = NSApplication.sharedApplication
worker = Sucker.new(
:locale => :us,
:key => aws_key,
:secret => aws_secret)
worker << {
'Operation' => 'ItemLookup',
'IdType' => 'ASIN',
'ItemId' => 'B000AMPZF8',
'ResponseGroup' => 'Images'
}
response = worker.get
width = 500.0
height = 500.0
frame = [0.0, 0.0, width, height]
mask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask
window = NSWindow.alloc.initWithContentRect(
frame,
styleMask:mask,
backing:NSBackingStoreBuffered,
defer:false)
content_view = NSImageView.alloc.initWithFrame(frame)
image_url = NSURL.URLWithString(response.find('LargeImage').first['URL'])
content_view.setImage(NSImage.alloc.initWithContentsOfURL(image_url))
window.contentView = content_view
window.center
window.display
window.makeKeyAndOrderFront(nil)
window.orderFrontRegardless
application.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment