ruby 从Riot ddragon cdn获取最新的冠军图标

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 从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

以上是关于ruby 从Riot ddragon cdn获取最新的冠军图标的主要内容,如果未能解决你的问题,请参考以下文章

riot.js教程组件撰写准则预处理器标签样式和装配方法

如何从Riot Games API中提取数据?

“伪区块链上市”Riot Blockchain被提起诉讼 涉嫌内幕信息交易

英雄联盟 Riot Games REST API 简析

白话快速理解CDN

CDN的智能调度,链路优化的详细解答