Class: Niconico::Live::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/niconico/live/util.rb

Class Method Summary collapse

Class Method Details

.fetch_token(agent) ⇒ Object



15
16
17
18
# File 'lib/niconico/live/util.rb', line 15

def fetch_token(agent)
  page = agent.get('http://live.nicovideo.jp/my')
  page.at('#confirm').attr('value')
end

.normalize_id(id, with_lv: true) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/niconico/live/util.rb', line 5

def normalize_id(id, with_lv: true)
  id = id.to_s

  if with_lv
    id.start_with?('lv') ? id : "lv#{id}"
  else
    id.start_with?('lv') ? id[2..-1] : id
  end
end