hardwired
11/23/2014 - 3:27 AM

Get latest champ icon from Riot ddragon cdn

Get latest champ icon from Riot ddragon cdn

require 'rubygems'
require 'json'
require 'open-uri'
 
def geticon
 
na = "http://ddragon.leagueoflegends.com/realms/na.json"
 
http = open("#{na}").read
hash = JSON.parser.new(http).parse()
cdn = hash['cdn']
c_version = hash['n']['champion']
i_version = hash['n']['item']
s_version = hash['n']['summoner']
m_version = hash['n']['mastery']

http = open("#{cdn}/#{c_version}/data/en_US/championFull.json").read
hash = JSON.parser.new(http).parse()
data = hash['data']
 
    data.each do |key, champ|
        c = champ['image']['full']
        url = "#{cdn}/#{c_version}/img/champion/#{c}"
        system "echo #{url} | xargs -P 5 wget -N"
    end

http = open("#{cdn}/#{i_version}/data/en_US/item.json").read
hash = JSON.parser.new(http).parse()
data = hash['data']

    data.each do |key, item|
        i = item['image']['full']
        url = "#{cdn}/#{i_version}/img/item/#{i}"
        system "echo #{url} | xargs -P 5 wget -N"
    end

http = open("#{cdn}/#{i_version}/data/en_US/summoner.json").read
hash = JSON.parser.new(http).parse()
data = hash['data']

    data.each do |key, spell|
        s = spell['image']['full']
        url = "#{cdn}/#{s_version}/img/spell/#{s}"
        system "echo #{url} | xargs -P 5 wget -N"
    end

http = open("#{cdn}/#{m_version}/data/en_US/mastery.json").read
hash = JSON.parser.new(http).parse()
data = hash['data']

    data.each do |key, mastery|
        m = mastery['image']['full']
        url = "#{cdn}/#{s_version}/img/mastery/#{m}"
        system "echo #{url} | xargs -P 5 wget -N"
    end

end

geticon