ruby-on-railsfeedjira

Parse youtube links with feedjira


I use rails 5.2, feedjira 2.1.0

If I parse youtube link

I have this error:

undefined method `image' for #Feedjira::Parser::AtomYoutubeEntry:0x00007fa14be348d0

other links work

my code:

def self.add_entries(entries, stream_id)
      entries.each do |entry|
          unless  FeedEntry.where(guid: entry.id).exists?
            FeedEntry.create!(
              :name          => entry.title,
              :url           => entry.url,
              :summary       => entry.summary,
              :published_at  => entry.published,
              :enclosure_url => entry.image,
              :enclosure_type => entry.enclosure_type,
              :guid          => entry.id,
              :source_id => stream_id
            )
          end
      end
end

How to make to parse all links?


Solution

  • You are expecting an image attribute but there is no attribute called image in AtomYoutubeEntry.

    Have a look at Feedjira on github. There is for example a media_thumbnail_url which you could use.