How to get videos from RSS feed entries
I am trying to get video (urls) from feed url.
I am using Feedjira and MetaInspector in my application to retrieve and store articles along with images. Now I want to store video of articles, if any. Can someone please tell me what the best ways to store videos from articles might be.
Thank.
source to share
I am doing this in my project to keep all urls found from rss feeds
Source.all.each do |source|
feed = Feedjira::Feed.fetch_and_parse(source.url)
feed.entries.each do |entry|
unless Link.exists? url: entry.url
Link.create!(title: entry.title,
url: entry.url)
end
end
end
in my snippet, I only keep the URL and title, for the videos you just need to add entry.video
,
you can see the whole post tag from object feed.entries
or from rss.
and if you want to add other attributes, ex: media:thumbnail
you can add this code before the call fetch_and_parse
, but you need to call it once not every time you call fetch_and_parse
to avoid memory leak
Feedjira::Feed.add_common_feed_entry_element("media:thumbnail", :value => :url, :as => :pic)
then you can do entry.pic
to get a sketch sketch
source to share