Class: RadikoPremium

Inherits:
Radiko show all
Defined in:
lib/rbtune/radiko_premium.rb

Direct Known Subclasses

TimeFree

Instance Attribute Summary

Attributes inherited from Radiko

#authtoken

Attributes inherited from Radio

#area_en, #area_id, #area_ja, #ext, #outdir

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Radiko

#authenticate1, #authenticate2, #channel_to_uri, #create_player, #open, #parse_stations, #read_partialkey

Methods inherited from Radio

#agent, bands, #channel_to_uri, channels, #convert, #convert_ffmpeg, #create_player, #datetime, db, #fetch_stations, find, inherited, #initialize, #make_recfile, #make_tmpfile, match, #open, #out_ext, #play, #record, search, stations, #tune

Constructor Details

This class inherits a constructor from Radio

Class Method Details

.set_authentication(kc, account) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rbtune/radiko_premium.rb', line 8

def self.set_authentication(kc, )
  begin
    password = kc.query('radikoプレミアムのパスワードを入力してください', )
    radio = RadikoPremium.new
    radio. , password
    kc.set , password
    puts "Radikoプレミアムのアカウントが正しく登録されました"

  rescue Radio::HTTPForbiddenException
    $stderr.puts "アカウント情報が正しくありません"

  rescue RuntimeError
    $stderr.puts $!

  ensure
    radio && radio.close
  end
end

Instance Method Details

#closeObject



57
58
59
60
61
62
# File 'lib/rbtune/radiko_premium.rb', line 57

def close
  params = []
  referer = nil
  agent.get 'https://radiko.jp/ap/member/webapi/member/logout', params, referer, headers
  @logged_in = false
end

#headersObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rbtune/radiko_premium.rb', line 28

def headers
  {
    'pragma'           => 'no-cache',
    'Cache-Control'    => 'no-cache',
    'Expires'          => 'Thu, 01 Jan 1970 00:00:00 GMT',
    'Accept-Language'  => 'ja-jp',
    'Accept-Encoding'  => 'gzip, deflate',
    'Accept'           => 'application/json, text/javascript, */*; q=0.01',
    'X-Requested-With' => 'XMLHttpRequest'
  }
end

#login(account, password) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rbtune/radiko_premium.rb', line 41

def (, password)
  res = agent.post 'https://radiko.jp/ap/member/login/login', {
    mail: , pass: password
  }

  begin
    params = []
    referer = nil
    @logged_in = true
    agent.get 'https://radiko.jp/ap/member/webapi/member/login/check', params, referer, headers
  rescue Mechanize::ResponseCodeError => ex
    raise HTTPForbiddenException if ex.message.include?('400 => Net::HTTPBadRequest')
  end
end

#stations_uriObject



64
65
66
# File 'lib/rbtune/radiko_premium.rb', line 64

def stations_uri
  "http://radiko.jp/v3/station/region/full.xml"
end