normalize_for_artist_finder!: Don't crash on bad URLs

If we can't normalize the URL (because of bad IDs, it's malformed, or
the HTML page changed), just return the unnormalized URL.
This commit is contained in:
evazion
2014-10-05 12:13:38 -05:00
parent dcbe061809
commit c75d2d208e
2 changed files with 11 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
# encoding: UTF-8
module Sources
class Error < Exception ; end
class Site
attr_reader :url, :strategy
delegate :get, :referer_url, :site_name, :artist_name, :profile_url, :image_url, :tags, :artist_record, :unique_id, :page_count, :to => :strategy
@@ -22,7 +24,11 @@ module Sources
def normalize_for_artist_finder!
if available?
return strategy.normalize_for_artist_finder!
begin
return strategy.normalize_for_artist_finder!
rescue Sources::Error
return url
end
else
return url
end