Class: ListenRadio

Inherits:
Radio
  • Object
show all
Defined in:
lib/rbtune/listenradio.rb

Direct Known Subclasses

Jcba

Instance Attribute Summary

Attributes inherited from Radio

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

Instance Method Summary collapse

Methods inherited from Radio

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

Constructor Details

#initializeListenRadio

Returns a new instance of ListenRadio.



14
15
16
17
# File 'lib/rbtune/listenradio.rb', line 14

def initialize
  super
  @ext = 'mp4'
end

Instance Method Details

#create_player(uri) ⇒ Object



19
20
21
22
23
24
# File 'lib/rbtune/listenradio.rb', line 19

def create_player(uri)
  player = FFMpeg.new
  player['i']      = uri     # input stream
  player['acodec'] = 'copy'  # acodecオプションはiオプションのあとに置かないとエラー
  player
end

#parse_stations(body) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rbtune/listenradio.rb', line 32

def parse_stations(body)
  json = JSON[body.body, symbolize_names: true]
  stations = json[:Channel].map do |station|
    name = station[:ChannelName]
    id   = station[:ChannelId]
    desc = station[:ChannelDetail]
    uri  = station[:ChannelHls]
    # puts "'#{name}' <#{uri}> #{desc}"
    Station.new(id, uri, name: name, description: desc)
  end
end

#stations_uriObject



27
28
29
# File 'lib/rbtune/listenradio.rb', line 27

def stations_uri
  'http://listenradio.jp/service/channel.aspx'
end