Class: Radiru
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, #create_player, #datetime, db, #fetch_stations, find, inherited, #initialize, #login, #make_recfile, #make_tmpfile, match, #open, #out_ext, #play, #record, search, stations, #tune
Constructor Details
This class inherits a constructor from Radio
Instance Method Details
#parse_stations(body) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rbtune/radiru.rb', line 14 def parse_stations(body) stations = body.search '//data' stationsjp = { 'r1' => "ラジオ第1", 'r2' => "ラジオ第2", 'fm' => "FM", } stations = stations.map do |station| areajp = station.at('areajp').text area = station.at('area').text # 地区ごとに第1, 第2, FM を登録する r1, r2, fm = %w(r1 r2 fm).map do |v| hls = "#{v}hls" id = "nhk#{v}-#{area}".upcase uri = station.at(hls).text name = "NHK#{stationsjp[v]}-#{areajp}" Station.new(id, uri, name: name, ascii_name: id) end end stations.flatten! # id: NHKR1, NHKR2, NHKFM を東京局に割り当てる stations.find_all { |station| station.id =~ /-TOKYO/}.reverse.map do |station| id = station.id.sub(/-TOKYO/, '') stations.unshift Station.new(id, station.uri, name: station.name, ascii_name: id) end stations end |
#stations_uri ⇒ Object
9 10 11 |
# File 'lib/rbtune/radiru.rb', line 9 def stations_uri "https://www.nhk.or.jp/radio/config/config_web.xml" end |