Sha256: 29945579929e9e3be9a81318c6d15cf3140d301bd9f5dd66d6097c2d5e01ce4d

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

module MusicBrainz
  class Base

    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

    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

  end



end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
musicbrainz_ruby-0.1.3 lib/musicbrainz/base.rb