5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/feedcellar/resource.rb', line 5
def self.parse(url)
begin
= RSS::Parser.parse(url)
rescue RSS::InvalidRSSError
= RSS::Parser.parse(url, false)
rescue
$stderr.puts "WARNING: #{$!} (#{url})"
return nil
end
unless
$stderr.puts "ERROR: Invalid URL"
return nil
end
resource = {}
if .is_a?(RSS::Atom::Feed)
resource["xmlUrl"] = url
resource["title"] = .title.content
resource["htmlUrl"] = .link.href
resource["description"] = .dc_description
else
resource["xmlUrl"] = url
resource["title"] = .channel.title
resource["htmlUrl"] = .channel.link
resource["description"] = .channel.description
end
resource
end
|