Sha256: 4ea75e39d5d8a94b6fe13e581b743e35b1abb1b7daef95557d0117042bcaba45

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

require 'httparty'

class Metalive::Shoutcast
  include HTTParty

  attr_accessor :server, :port, :password

  def initialize(options = {})
    options = { :port => 8000 }.update(options)
    options.each_pair { |k,v| send("#{k}=", v) }
  end

  def query(song)
    { :mode => "updinfo", :song => song, :pass => password }
  end

  def base_uri
    "http://#{server}:#{port}"
  end

  def path
    "/admin.cgi"
  end

  def headers
    { "User-Agent" => "ShoutcastDSP (Mozilla Compatible)" }
  end

  def update(metadata)
    song = (Hash === metadata ? metadata[:song] : metadata.to_s)
    self.class.get path, :base_uri => base_uri, :query => query(song), :headers => headers
    true
  rescue => e
    false
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metalive-0.0.2 lib/metalive/shoutcast.rb
metalive-0.0.1 lib/metalive/shoutcast.rb