Skip to content

Instantly share code, notes, and snippets.

@joshavant
Created December 4, 2014 08:53
Show Gist options
  • Save joshavant/68a33519ec39f081bf48 to your computer and use it in GitHub Desktop.
Save joshavant/68a33519ec39f081bf48 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Installation:
# -`gem install httparty`
# -Install ImageMagick
# -`gem install mini_magick` + test (more info: https://github.com/minimagick/minimagick)
# -Configure DESTINATION_FILEPATH
# -Run it.
require 'httparty'
require 'json'
require 'mini_magick'
APP_STORE_IDS = { "tinder" => 547702041,
"merchbar" => 879654508,
"alltrails" => 405075943,
"livingsocial" => 340295413}
# requires trailing slash (i.e. '/foo/bar/`)
DESTINATION_FILEPATH = '/Users/josh/Development/iamjosh/source/images/app_icons/'
##########################################
# DO NOT EDIT BELOW THIS LINE
##########################################
APP_STORE_IDS.each do |key, app_store_id|
app_store_response = HTTParty.get("https://itunes.apple.com/lookup?id=" + app_store_id.to_s)
if app_store_response.success?
json = JSON.parse(app_store_response.body)
app_icon_url = json['results'].first['artworkUrl512']
app_icon_response = HTTParty.get(app_icon_url)
if app_icon_response.success?
app_icon = MiniMagick::Image.read(app_icon_response.parsed_response)
app_icon.resize "175x175"
app_icon.write(DESTINATION_FILEPATH + key + ".png")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment