Skip to content

Instantly share code, notes, and snippets.

@metade
Created February 4, 2009 09:28
Show Gist options
  • Save metade/58033 to your computer and use it in GitHub Desktop.
Save metade/58033 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'hpricot'
require 'yaml'
task :convert_data do
doc = Hpricot(File.open('b00h752w.html'))
artists = (doc/'//a').map { |a| { :link =>a['href'], :name => a.inner_html, :offset => nil } }
File.open('data.yml', 'w') { |file| file.puts artists.to_yaml }
end
task :fetch_artists do
artists = YAML.load_file('data.yml')
artists[0,10].each do |artist|
gid = artist[:link].sub('http://www.bbc.co.uk/music/artists/', '')
`CutyCapt --out=artists/#{gid}.png --url=#{artist[:link]}`
end
end
task :crop_images do
artists = YAML.load_file('data.yml')
artists[0,10].each do |artist|
gid = artist[:link].sub('http://www.bbc.co.uk/music/artists/', '')
`convert -crop '974x548+0+111!' artists/#{gid}.png cropped/#{gid}.png`
end
end
task :draw_background do
`convert -size 974x548 xc:none -fill white -draw 'rectangle 0,0 974,548' background.png`
end
task :compose_images do
artists = YAML.load_file('data.yml')
artists[0,10].each do |artist|
gid = artist[:link].sub('http://www.bbc.co.uk/music/artists/', '')
`composite -compose src-over -size 974x548 cropped/#{gid}.png background.png composed/#{gid}.png`
end
end
task :setup_frames do
artists = YAML.load_file('data.yml')
offset = 0
`rm frames/*`
artists[0,10].each do |artist|
gid = artist[:link].sub('http://www.bbc.co.uk/music/artists/', '')
`ln composed/#{gid}.png frames/image#{artist[:offset]}.png`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment