lib/imasquerade/extractor.rb in imasquerade-0.1.1 vs lib/imasquerade/extractor.rb in imasquerade-0.1.2
- old
+ new
@@ -17,11 +17,17 @@
def Extractor.fetch_and_parse_feed_from_apple(id)
uri = "http://itunes.apple.com/podcast/id#{id}"
response = Curl::Easy.perform(uri) do |curl|
curl.headers["User-Agent"] = 'iTunes/10.1.1'
end
- reader = Nokogiri::XML(response.body_str)
- array_of_feeds = reader.xpath('//xmlns:key[text()="feedURL"]/following-sibling::xmlns:string[1]/text()')
- return array_of_feeds[0].to_s
+ # In case there is some sort of error
+ begin
+ reader = Nokogiri::XML(response.body_str)
+ array_of_feeds = reader.xpath('//xmlns:key[text()="feedURL"]/following-sibling::xmlns:string[1]/text()')
+ return array_of_feeds[0].to_s
+ rescue Nokogiri::XML::SyntaxError => e
+ puts "Caught exception: #{e}"
+ return ""
+ end
end
end
end
\ No newline at end of file