Sha256: 9cfe7da9281fa3bf2334694b70dc67895d84ab5a5d148f9038164486a044f517
Contents?: true
Size: 644 Bytes
Versions: 2
Compression:
Stored size: 644 Bytes
Contents
module MusicBrainz @@last_query_time = 0 @@query_interval = 1.5 # Min: 1.0 Safe: 1.5 def self.query_interval= sec @@query_interval = sec.to_f end def self.load url 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) @@last_query_time = Time.now.to_f rescue => e # MusicBrainz: 503 end break unless response.nil? end response end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
musicbrainz-0.4.5 | lib/models/music_brainz.rb |
musicbrainz-0.4.4 | lib/models/music_brainz.rb |