lib/imasquerade/extractor.rb in imasquerade-0.2.1 vs lib/imasquerade/extractor.rb in imasquerade-0.2.2
- old
+ new
@@ -48,16 +48,22 @@
id = Extractor.itunes_id(url)
response = Extractor.get_raw_string(url)
reader = Nokogiri::XML(response)
feed_url = reader.xpath('//@feed-url')
return feed_url[0].value unless feed_url.count == 0
- list = Plist::parse_xml(response)
+ response.force_encoding("UTF-8") if response.encoding == Encoding::ASCII_8BIT
+ begin
+ list = Plist::parse_xml(response)
+ rescue RuntimeError => bang
+ list = {}
+ end
if list.has_key?('action') && list['action']['kind'] == "Goto" then
response = Extractor.fetch_and_parse_feed_from_apple(list['action']['url'])
return response
elsif list.has_key?('dialog')
throw list['dialog']['explanation']
end
File.open("#{id}.html", 'w') {|f| f.write(response) }
+ throw "The feed was either empty, or mal-formed."
end
end
end