Class: Metalive::Icecast

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/metalive/icecast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Icecast

Returns a new instance of Icecast.



8
9
10
11
# File 'lib/metalive/icecast.rb', line 8

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

Instance Attribute Details

#mountObject

Returns the value of attribute mount.



6
7
8
# File 'lib/metalive/icecast.rb', line 6

def mount
  @mount
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/metalive/icecast.rb', line 6

def password
  @password
end

#portObject

Returns the value of attribute port.



6
7
8
# File 'lib/metalive/icecast.rb', line 6

def port
  @port
end

#serverObject

Returns the value of attribute server.



6
7
8
# File 'lib/metalive/icecast.rb', line 6

def server
  @server
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/metalive/icecast.rb', line 6

def username
  @username
end

Instance Method Details

#authenticationObject



13
14
15
# File 'lib/metalive/icecast.rb', line 13

def authentication
  { :username => username, :password => password }
end

#base_uriObject



25
26
27
# File 'lib/metalive/icecast.rb', line 25

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

#pathObject



29
30
31
# File 'lib/metalive/icecast.rb', line 29

def path
  "/admin/metadata"
end

#query(song) ⇒ Object



17
18
19
# File 'lib/metalive/icecast.rb', line 17

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

#update(metadata) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/metalive/icecast.rb', line 33

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