Skip to content

Instantly share code, notes, and snippets.

@karlentwistle
Created November 24, 2012 18:52
Show Gist options
  • Save karlentwistle/4140931 to your computer and use it in GitHub Desktop.
Save karlentwistle/4140931 to your computer and use it in GitHub Desktop.
Recent Documentaries on Reddit
require 'open-uri'
require 'nokogiri'
require 'video_info'
def extract_youtube_links(link)
top_docs = Nokogiri::XML(open(link))
links = URI.extract(top_docs.xpath('//item/description').to_a.join(" "))
links.select { |l| l.include?("watch?v=") }
end
def video_info(links)
links.map { |link| VideoInfo.new(link) }
end
links = extract_youtube_links("http://www.reddit.com/r/documentaries.rss?limit=100")
puts video_info(links).map { |vi| { title: vi.title, link: vi.embed_url } }
@karlentwistle
Copy link
Author

An easier way to consume www.reddit.com/r/documentaries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment