Skip to content

Instantly share code, notes, and snippets.

@clicube
Created November 3, 2011 09:49
Show Gist options
  • Save clicube/1336156 to your computer and use it in GitHub Desktop.
Save clicube/1336156 to your computer and use it in GitHub Desktop.
jubegraph auto updater (copious)
# coding: utf-8
require 'mechanize'
id = ''
pass = ''
url_login = 'http://p.eagate.573.jp/gate/p/login.html'
url_player = 'http://p.eagate.573.jp/game/jubeat/copious/p/playdata/index.html'
url_music1 = 'http://p.eagate.573.jp/game/jubeat/copious/p/playdata/music.html?page=1'
url_music2 = 'http://p.eagate.573.jp/game/jubeat/copious/p/playdata/music.html?page=2'
url_music3 = 'http://p.eagate.573.jp/game/jubeat/copious/p/playdata/music.html?page=3'
agent = Mechanize.new
puts "Logging in... (#{url_login})"
agent.get(url_login)
agent.page.encoding = 'CP932'
agent.page.form_with(:action=>'/gate/p/login.html') do |form|
form.field_with(:name=>'KID').value = id
form.field_with(:name=>'pass').value = pass
form.submit
end
puts "Player Data... (#{url_player})"
html_player = agent.get_file(url_player)
puts "Music Data1... (#{url_music1})"
html_music1 = agent.get_file(url_music1)
puts "Music Data2... (#{url_music2})"
html_music2 = agent.get_file(url_music2)
puts "Music Data3... (#{url_music3})"
html_music3 = agent.get_file(url_music3)
# ページ読み込み完了
# 次はjubegraphにアップロード
url_jbg = 'http://jubegraph.dyndns.org/jubeat_copious/'
puts "Jubegraph page... (#{url_jbg})"
agent.get(url_jbg)
agent.page.form_with(:action=>'cgi/registFile.cgi') do|form|
form.file_upload_with(:name=>'playerData') do |fu|
fu.file_data = html_player
fu.mime_type = 'text/html'
fu.file_name = 'playerData.html'
end
form.file_upload_with(:name=>'musicData1') do |fu|
fu.file_data = html_music1
fu.mime_type = 'text/html'
fu.file_name = 'musicData1.html'
end
form.file_upload_with(:name=>'musicData2') do |fu|
fu.file_data = html_music2
fu.mime_type = 'text/html'
fu.file_name = 'musicData2.html'
end
form.file_upload_with(:name=>'musicData3') do |fu|
fu.file_data = html_music3
fu.mime_type = 'text/html'
fu.file_name = 'musicData3.html'
end
form.submit
end
# 出力をチェック & 送信ボタン押す
html_jbg = agent.page.root.inner_html
form = agent.page.form_with(:action=>'registData.cgi')
if html_jbg.include?("取得できていない情報があります。") || html_jbg.include?("曲データがありません。") || !form
puts "something wrong with data or time limitation."
puts "failed."
else
puts "Jubegraph updating..."
form.submit
puts "complete."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment