scripts/shoutcast_test.rb
# Fetches the show title from the live stream defined by URI
Fetches the show title from the live stream defined by URI
Fetches the show title from the live stream defined by URI
def fetch_show
  @last_update = Time.now
  http = Net::HTTP.new(SHOUTCAST_URI.host, SHOUTCAST_URI.port)
  chunk_count = 0
  chunk_limit = 20 
  http.get(SHOUTCAST_URI.path, HEADERS) do |chunk|
    chunk_count += 1
    if chunk =~ /StreamTitle='(.+?)';/
      p chunk
      return $1
      break;
    elsif chunk_count > chunk_limit
      return nil
    end
  end
end
def fetch_show @last_update = Time . now http = Net :: HTTP . new ( SHOUTCAST_URI . host , SHOUTCAST_URI . port ) chunk_count = 0 chunk_limit = 20 http . get ( SHOUTCAST_URI . path , HEADERS ) do | chunk | chunk_count += 1 if chunk =~ / StreamTitle='(.+?)'; / p chunk return $1 break ; elsif chunk_count > chunk_limit return nil end end end
Fetches the show title from the live stream defined by URI
Fetches the show title from the live stream defined by URI
# Limit chunks to prevent lockups