Last active
December 9, 2019 20:48
-
-
Save takehiko/6692419f0549d3a3187131d5fac79f35 to your computer and use it in GitHub Desktop.
Version extractor for beatmania IIDX ULTIMATE MOBILE
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
#!/usr/bin/env ruby | |
require "kconv" | |
# iidxum-versionpicker.rb : Version extractor for beatmania IIDX ULTIMATE MOBILE | |
# by takehikom | |
# see also: https://takehikom.hateblo.jp/entry/2019/12/10/000000 | |
# 通信せず、27.0(という名前)のファイルを読み出して、 | |
# game_idの値とバージョン名を見つけ、カンマ区切りで出力する | |
class IIDXumVersionpicker | |
# def initialize; end | |
def pick_version | |
html = open("27.0").read | |
html2 = html.toutf8 | |
# html2.sub!(/charset=shift.?jis/, "charset=utf-8") | |
result = [] | |
html2.scan(/<option .*?game_id=(.*?)".*?>(.*?)<\/option>/) do |u, v| | |
# '<option value="/game/2dx/mobile/music/game.html?game_id=27.0" selected >beatmania IIDX 27 HEROIC VERSE</option>' | |
# のとき,u = '27.0', v = 'beatmania IIDX 27 HEROIC VERSE' | |
result << [u.to_f, v.strip] | |
end | |
result | |
end | |
def start | |
result = pick_version.sort_by { |item| item.first } | |
result.each do |u, v| | |
print "#{u},#{v}\r\n" | |
end | |
end | |
end | |
if __FILE__ == $0 | |
IIDXumVersionpicker.new.start | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment