Created
July 21, 2016 02:02
-
-
Save cheebow/0a5262420cd8450a70507f8f33e62729 to your computer and use it in GitHub Desktop.
TIF2016出演アイドル別に出演時間を表示する
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
require 'open-uri' | |
require 'json' | |
response = open('http://www.idolfes.com/2016/json/timetable/time.json') | |
data = response.read | |
json = JSON.parse(data) | |
artists = {} | |
json.keys.each{|day| | |
json[day].keys.each{|stage| | |
json[day][stage].each{|item| | |
item["day"] = day | |
item["stage"] = stage | |
if !artists[item["artist"]] | |
artists[item["artist"]] = [] | |
end | |
artists[item["artist"]].push(item) | |
} | |
} | |
} | |
artists.keys.each{|artist| | |
puts "*" + artist | |
items = artists[artist] | |
items.each{|item| | |
puts "\t" + item["day"] + "[" + item["stage"] + "]" "(" + item["start"] + "-" + item["end"] + ")" | |
} | |
} |
https://gist.github.com/iorionda/39993c3998c79945ed61fdccd83250dc
require 'open-uri'
require 'json'
response = open('http://www.idolfes.com/2016/json/timetable/time.json')
data = JSON.parse(response.read)
artists = {}
data.each do |day, stages|
stages.each do |stage, items|
items.each do |item|
(artists[item["artist"]] ||= []) << item.merge(
'day' => day,
'stage' => stage
)
end
end
end
artists.keys.each do |artist|
puts "*#{artist}"
items = artists[artist]
items.each do |item|
puts "\t#{item['day']}[#{item['stage']}](#{item['start']}-#{item['end']})"
end
end
こんな感じですかねえ。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
出力結果