Module: AudioDB

Defined in:
lib/audiodb.rb,
lib/audiodb/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.discography(s) ⇒ Object

  • `s` artist name

return Discography for an Artist with Album names and year only

Raises AudioDBException



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/audiodb.rb', line 58

def discography(s)
  begin
    response = get_request("discography.php?s=#{ERB::Util.url_encode(s)}")
    if response.length == 0
      raise AudioDBException.new("no results found")
    end
    json = JSON.parse(response)
    if json['album'] == nil
      raise AudioDBException.new("no results found")
    end
    return json['album']
  rescue => ex
    raise AudioDBException.new(ex.message)
  end
end

.search_album_by_id(i) ⇒ Object

  • `i` album id

return individual Album info using known Album ID

Raises AudioDBException



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/audiodb.rb', line 104

def search_album_by_id(i)
  begin
    response = get_request("album.php?m=#{i}")
    if response.length == 0
      raise AudioDBException.new("no results found")
    end
    json = JSON.parse(response)
    if json['album'] == nil
      raise AudioDBException.new("no results found")
    end
    return json['album'][0]
  rescue => ex
    raise AudioDBException.new(ex.message)
  end
end

.search_albums_by_artist_id(i) ⇒ Object

  • `i` artist id

return All Albums for an Artist using known Artist ID

Raises AudioDBException



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/audiodb.rb', line 127

def search_albums_by_artist_id(i)
  begin
    response = get_request("album.php?i=#{i}")
    if response.length == 0
      raise AudioDBException.new("no results found")
    end
    json = JSON.parse(response)
    if json['album'] == nil
      raise AudioDBException.new("no results found")
    end
    return json['album']
  rescue => ex
    raise AudioDBException.new(ex.message)
  end
end

.search_artist(s) ⇒ Object

  • `s` artist name

return Artist details from artist name

Raises AudioDBException



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/audiodb.rb', line 35

def search_artist(s)
  begin
    response = get_request("search.php?s=#{ERB::Util.url_encode(s)}")
    if response.length == 0
      raise AudioDBException.new("no results found")
    end
    json = JSON.parse(response)
    if json['artists'] == nil
      raise AudioDBException.new("no results found")
    end
    return json['artists'][0]
  rescue => ex
    raise AudioDBException.new(ex.message)
  end
end

.search_artist_by_id(i) ⇒ Object

  • `i` artist id

return individual Artist details using known Artist ID

Raises AudioDBException



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/audiodb.rb', line 81

def search_artist_by_id(i)
  begin
    response = get_request("artist.php?i=#{i}")
    if response.length == 0
      raise AudioDBException.new("no results found")
    end
    json = JSON.parse(response)
    if json['artists'] == nil
      raise AudioDBException.new("no results found")
    end
    return json['artists'][0]
  rescue => ex
    raise AudioDBException.new(ex.message)
  end
end

.search_music_videos_by_artist_id(i) ⇒ Object

  • `i` artist id

return all the Music videos for a known Artist ID

Raises AudioDBException



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/audiodb.rb', line 196

def search_music_videos_by_artist_id(i)
  begin
    response = get_request("mvid.php?i=#{i}")
    if response.length == 0
      raise AudioDBException.new("no results found")
    end
    json = JSON.parse(response)
    if json['mvids'] == nil
      raise AudioDBException.new("no results found")
    end
    return json['mvids']
  rescue => ex
    raise AudioDBException.new(ex.message)
  end
end

.search_track_by_id(i) ⇒ Object

  • `i` track id

return individual track info using a known Track ID

Raises AudioDBException



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/audiodb.rb', line 173

def search_track_by_id(i)
  begin
    response = get_request("track.php?h=#{i}")
    if response.length == 0
      raise AudioDBException.new("no results found")
    end
    json = JSON.parse(response)
    if json['track'] == nil
      raise AudioDBException.new("no results found")
    end
    return json['track'][0]
  rescue => ex
    raise AudioDBException.new(ex.message)
  end
end

.search_tracks_by_album_id(i) ⇒ Object

  • `i` album id

return All Tracks for Album from known Album ID

Raises AudioDBException



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/audiodb.rb', line 150

def search_tracks_by_album_id(i)
  begin
    response = get_request("track.php?m=#{i}")
    if response.length == 0
      raise AudioDBException.new("no results found")
    end
    json = JSON.parse(response)
    if json['track'] == nil
      raise AudioDBException.new("no results found")
    end
    return json['track']
  rescue => ex
    raise AudioDBException.new(ex.message)
  end
end