Class: MusicBrainz::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/musicbrainz/base.rb

Direct Known Subclasses

Artist, Label, Query, Recording, Release, ReleaseGroup, Work

Class Method Summary collapse

Class Method Details

.get(method, mbid, query) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/musicbrainz/base.rb', line 4

def self.get(method, mbid, query)
  if method=='search'

    includes="?query=#{query}" unless query==[]
  else
    includes="?inc=#{query}" unless query==[]
  end
  path="/ws/2/#{method}/#{mbid}#{includes}"
  uri_host="musicbrainz.org"
  uri_port="80"
  http = Net::HTTP.new(uri_host, uri_port).get(path)
  response = http.response.code
  body = http.response.body

  body=Hash.from_xml(body)
  if response=="200"
    return body
  else
    return false
  end


end

.get_query_path(method, query) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/musicbrainz/base.rb', line 28

def self.get_query_path(method, query)

  inc="?query=#{query}"
  path="/ws/2/#{method}#{inc}"
  uri_host="musicbrainz.org"
  uri_port="80"
  puts path
  http = Net::HTTP.new(uri_host, uri_port).get(path)
  response = http.response.code
  body = http.response.body

  body=Hash.from_xml(body)
  if response=="200"
    return body
  else
    return false
  end

end