Module: Bnicovideo::UserSession::WinXp
- Defined in:
- lib/bnicovideo/user_session/win_xp.rb
Class Method Summary collapse
Class Method Details
.init_from_chrome ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/bnicovideo/user_session/win_xp.rb', line 50 def self.init_from_chrome sql_path = File.join(ENV['APPDATA'], 'Google', 'Chrome', 'User Data', 'Default', 'Cookies') conn = SQLite3::Database.new(sql_path) val = conn.get_first_value("select value from cookies" + " where host_key='.nicovideo.jp' AND name='user_session'") conn.close return val end |
.init_from_firefox ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bnicovideo/user_session/win_xp.rb', line 11 def self.init_from_firefox base_path = File.join(ENV['APPDATA'], 'Mozilla', 'Firefox') ini_path = File.join(base_path, 'profiles.ini') ini_hash = IniFile.load(ini_path).to_h profile_path = nil ini_hash.each do |k, v| next unless v['Name'] == 'default' relative = (v['IsRelative'] != '0') input_path = v['Path'] if relative profile_path = File.join(base_path, input_path) else profile_path = input_path end sql_path = File.join(profile_path, 'cookies.sqlite') conn = SQLite3::Database.new(sql_path) val = conn.get_first_value("select value from moz_cookies" + " where host='.nicovideo.jp' AND name='user_session'") return val end return nil end |
.init_from_ie ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bnicovideo/user_session/win_xp.rb', line 33 def self.init_from_ie = File.join(ENV['USERPROFILE'], 'Cookie') Dir.open() do |dir| dir.each do |fn| next unless (/.*@nicovideo.*/ =~ fn) File.open(fn) do |f| cb = f.read cs = cb.split(/\*\n/) cs.each do |c| ca = c.split(/\n/) return ca[1] if ca[0] == 'user_session' end end end end return nil end |