404 error handling
This commit is contained in:
parent
6038ea8def
commit
684104b2b3
@ -14,7 +14,7 @@ module MusicBrainz
|
|||||||
response = open(url, "User-Agent" => "gem musicbrainz (https://github.com/magnolia-fan/musicbrainz) @ " + Socket.gethostname)
|
response = open(url, "User-Agent" => "gem musicbrainz (https://github.com/magnolia-fan/musicbrainz) @ " + Socket.gethostname)
|
||||||
@@last_query_time = Time.now.to_f
|
@@last_query_time = Time.now.to_f
|
||||||
rescue => e
|
rescue => e
|
||||||
# MusicBrainz: 503
|
return nil if e.io.status[0].to_i == 404
|
||||||
end
|
end
|
||||||
break unless response.nil?
|
break unless response.nil?
|
||||||
end
|
end
|
||||||
|
@ -16,7 +16,9 @@ module MusicBrainz
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.find mbid
|
def self.find mbid
|
||||||
@artist = self.parse_xml(Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/artist/' + mbid)))
|
res = MusicBrainz.load('http://musicbrainz.org/ws/2/artist/' + mbid)
|
||||||
|
return nil if res.nil?
|
||||||
|
@artist = self.parse_xml(Nokogiri::XML())
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.parse_xml xml
|
def self.parse_xml xml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user