Created
November 24, 2012 18:52
-
-
Save karlentwistle/4140931 to your computer and use it in GitHub Desktop.
Recent Documentaries on Reddit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An easier way to consume www.reddit.com/r/documentaries