Skip to content

Instantly share code, notes, and snippets.

@utahta
Created November 9, 2014 16:18
Show Gist options
  • Select an option

  • Save utahta/e9f665cd4f94b9eb33ae to your computer and use it in GitHub Desktop.

Select an option

Save utahta/e9f665cd4f94b9eb33ae to your computer and use it in GitHub Desktop.
maimai play data to json
require 'maimailog'
require 'json'
require 'optparse'
require 'io/console'
opts = {}
opt = OptionParser.new
opt.on('-u USERID', 'maimainet user id') { |v| opts[:u] = v }
opt.on('-p', 'maimainet password') { |v| opts[:p] = v }
opt.parse!(ARGV)
if opts[:u].nil? || opts[:p].nil?
puts opt.help
exit
end
print 'enter password: '
opts[:p] = STDIN.noecho(&:gets).strip
c = Maimailog::Crawler::History.new
c.login(opts[:u], opts[:p])
json_obj = []
c.fetch_all do |data|
p data
json_obj.push({
date: data.date,
difficulty: data.difficulty,
name: data.name,
judge: {
perfect: data.judge.perfect,
great: data.judge.great,
good: data.judge.good,
miss: data.judge.miss,
total: data.judge.total
},
score: {
rate: data.score.rate,
tap: data.score.tap,
hold: data.score.hold,
slide: data.score.slide,
break: data.score.break,
total: data.score.total,
tap_max: data.score.tap_max,
hold_max: data.score.hold_max,
slide_max: data.score.slide_max,
break_max: data.score.break_max,
total_max: data.score.total_max
}
})
end
open('playdata.json', 'w') do |fp|
JSON.dump(json_obj, fp)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment