Repository URL to install this package:
|
Version:
1.1.1 ▾
|
require "nokogiri"
module JApiAgent::ContentParser
class FlickrParser
FLICKR_FEED_MAPPING = {
:published_date => :published,
:content => :title,
:content_source => :url
}
def self.parse(posts)
parsed_posts = []
default_options = { :platform => "Flickr" }
posts.entries.each do |p|
post_hash = {}
FLICKR_FEED_MAPPING.each {|k,v| post_hash[k] = p.send(v)}
post_hash.merge!(default_options)
pp = Post.new(post_hash)
a = Nokogiri::HTML(p.content)
b = a.xpath("//img")
b.each do |x|
if x["src"]
pp.post_image = x["src"]
end
end
pp.author = {:name=>p.author}
parsed_posts << pp
end
parsed_posts
end
end
end