Parse youtube links with feedjira

103 Views Asked by At

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?

1

There are 1 best solutions below

2
PascalTurbo On BEST ANSWER

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.