lib/models/music_brainz.rb in musicbrainz-0.4.0 vs lib/models/music_brainz.rb in musicbrainz-0.4.1

- old
+ new

@@ -1,32 +1,19 @@ module MusicBrainz @@last_query_time = 0 - - def self.last_query_time - @@last_query_time - end - - def self.last_query_time= time - @@last_query_time = time - end + @@query_interval = 1.1 def self.load url - sleep 1.1 - (Time.now.to_f - self.last_query_time) if Time.now.to_f - self.last_query_time < 1.1 + sleep @@query_interval - (Time.now.to_f - @@last_query_time) if Time.now.to_f - @@last_query_time < @@query_interval response = nil 5.times do begin response = open(url, "User-Agent" => "gem musicbrainz (https://github.com/magnolia-fan/musicbrainz) @ " + Socket.gethostname) - self.last_query_time = Time.now.to_f + @@last_query_time = Time.now.to_f rescue => e p "MusicBrainz: 503" end break unless response.nil? end response - end - - def self.discography mbid - artist = MusicBrainz::Artist.find(mbid) - artist.release_groups.each {|rg| rg.releases.each {|r| r.tracks } } - artist end end