Skip to content

Instantly share code, notes, and snippets.

@blanco
Last active March 5, 2016 16:45
Show Gist options
  • Select an option

  • Save blanco/9905779 to your computer and use it in GitHub Desktop.

Select an option

Save blanco/9905779 to your computer and use it in GitHub Desktop.
Download ITMS 600x600 and 1200x1200 to Downloads folder
#! /usr/bin/ruby
# This script will grab both 600 x 600 and 1200 x 1200 album art from ITMS and download it to
# the ~/Downloads folder. Copy the album’s ITMS URL to the clipboard before running the script.
# It should be an URL from iTunes, such as: "https://itunes.apple.com/us/album/sonic-highways/id910701272"
# updated 2016-03-05
# lives at: https://gist.github.com/blanco/9905779
require 'cgi'
urlclip = IO.popen('pbpaste', 'r+').read
# https://itunes.apple.com/us/album/spilt-milk/id723680259
title_line = %x( curl #{urlclip} | grep -m 1 'meta content' )
result_title = title_line.gsub(/^.+<meta content=\"(.+) by (.+) on iTunes" property=\"og:title\".+$/, '\2 - \1')
jpgname = CGI.unescapeHTML(result_title).chop
jpgline = %x( curl #{urlclip} | grep 170x170 )
jpg600 = jpgline.gsub(/^.+(http:.+)cover170x170.+$/, '\1cover600x600.jpeg').chomp
jpg1200 = jpg600.gsub(/(.+)600x600(.+)/, '\11200x1200\2')
%x( cd ~/Downloads/ ; curl -o "#{jpgname} - 600.jpg" #{jpg600} )
%x( cd ~/Downloads/ ; curl -o "#{jpgname} - 1200.jpg" #{jpg1200} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment