Skip to content

Instantly share code, notes, and snippets.

Created April 28, 2012 11:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2518355 to your computer and use it in GitHub Desktop.
Save anonymous/2518355 to your computer and use it in GitHub Desktop.
yukelog
#! /usr/bin/ruby -Ku
$udid = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
HOST = 'yukeyusha4iphone.appspot.com'
YYVER = '3.0.1'
require 'net/https'
require 'rubygems'
require 'json'
class Connection
attr_accessor :accountid
def initialize clientid
@clientid = clientid
@https = nil
end
def start
@https = Net::HTTP.new HOST, 443
@https.use_ssl = true
@https.verify_mode = OpenSSL::SSL::VERIFY_NONE
@https.start
end
def finish
@https.finish
end
def post path, params={}
header = {'Host'=>HOST, 'Accept'=>'*/*',
'User-Agent'=>"Yukeyusha/#{YYVER} CFNetwork/548.0.4 Darwin/11.0.0",
'Accept-Language'=>'ja-jp', 'Accept-Encoding'=>'gzip, deflate',}
path = "#{path}?clientid=#{@clientid}&version=#{YYVER}"
params = params.merge 'accountid'=>@accountid if @accountid
body = params.select {|k, v| v}.map {|k, v| "#{k}=#{v}"}.join '&'
res = @https.post path, body, header
unless res.code == '200'
raise RuntimeError, "HTTPS response error #{res.code}"
end
res
end
end
c = Connection.new $udid
c.start
res = c.post '/account/sync'
c.accountid = JSON.parse(res.body)['account']['key']
res = c.post '/quest/list'
if item = JSON.parse(res.body)['data'].first
sdate = Time.at(item['startAt']/1000).strftime '%Y-%m-%d %H:%M:%S'
edate = Time.at(item['endAt']/1000).strftime '%Y-%m-%d %H:%M:%S'
s = item['success'] ? 'S' : 'F'
puts "#{s} #{sdate} - #{edate} #{item['dungeonName']} #{item['floor']}F"
res = c.post '/quest/download', 'questid'=>item['id']
JSON.parse(res.body)['data']['detailList'].each {|d|
date = Time.at(d['date']/1000).strftime '%H:%M:%S'
puts "#{date} #{d['status']} #{d['title']}"
if d['hasTimelines']
d['timeLineList'].each {|tl| puts " #{tl['title']} #{tl['detail']}"}
end
}
else
puts 'no quest'
end
c.finish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment