Class: SeasideCommnunications
Instance Method Summary collapse
Methods inherited from WebRadio
Constructor Details
This class inherits a constructor from WebRadio
Instance Method Details
#download(name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/seaside-c.rb', line 4 def download(name) html = open(@url, &:read) playlist_url, serial = html.scan(%r[(http:.*?\_(\d+).wax)]).flatten unless playlist_url raise WebRadio::DownloadError.new("recent radio program not found.") end serial = serial.to_i playlist = open(playlist_url, &:read) wma_url, = playlist.scan(%r[http://.*?\.wma]) @wma_file = "#{name}##{serial}.wma" @mp3_file = @wma_file.sub(/\.wma$/, '.mp3') mp3nize(@wma_file, @mp3_file) do open(@wma_file, 'wb:ASCII-8BIT') do |wma| wma.write(open(wma_url, &:read)) end end end |