Created
August 14, 2015 16:23
-
-
Save jerhinesmith/258eab7a892c87769115 to your computer and use it in GitHub Desktop.
Grab all NBA team logos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
teams = { | |
atl: 'hawks', | |
bkn: 'nets', | |
bos: 'celtics', | |
cha: 'hornets', | |
chi: 'bulls', | |
cle: 'cavaliers', | |
dal: 'mavericks', | |
den: 'nuggets', | |
det: 'pistons', | |
gsw: 'warriors', | |
hou: 'rockets', | |
ind: 'pacers', | |
lac: 'clippers', | |
lal: 'lakers', | |
mem: 'grizzlies', | |
mia: 'heat', | |
mil: 'bucks', | |
min: 'timberwolves', | |
nop: 'pelicans', | |
nyk: 'knicks', | |
okc: 'thunder', | |
orl: 'magic', | |
phi: '76ers', | |
phx: 'suns', | |
por: 'blazers', | |
sac: 'kings', | |
sas: 'spurs', | |
tor: 'raptors', | |
uta: 'jazz', | |
was: 'wizards' | |
} | |
teams.each do |abbreviation, name| | |
url = "http://i.cdn.turner.com/nba/nba/.element/img/1.0/teamsites/logos/teamlogos_500x500/#{abbreviation}.png" | |
print "Downloading #{name} (#{url})..." | |
open("#{name}.png", 'wb') do |file| | |
file << open(url).read | |
end | |
# Store the thumbnail | |
`convert #{name}.png -resize 128x128 #{name}_logo.png` | |
puts "DONE" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment