Created
December 3, 2015 18:13
-
-
Save ashfurrow/c2449f0a159bf7a06357 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'nokogiri' | |
require 'open-uri' | |
require 'cgi' | |
episodes = Array.new | |
doc = Nokogiri::HTML(open("http://www.notificationcenter.tv/feed.rss")) | |
episodes = doc.xpath("//item") | |
episodes.reverse.each do |e| | |
title = e.xpath("title").map { |node| node.text.strip }.first | |
date = e.xpath("pubdate").map { |node| node.text.strip }.first | |
description = e.xpath("description").map { |node| node.text.strip }.first | |
audio = e.xpath("enclosure").map { |node| [node.attributes["url"], node.attributes["length"]] }.first | |
duration = e.xpath("duration").map { |node| CGI.unescapeHTML(node.text.strip) }.first | |
content = e.xpath("//encoded").map { |node| node.text.strip }.first | |
tree = Nokogiri::HTML(content) | |
anchors = tree.xpath("//li/a") | |
links = anchors.map { |node| [node.text, node.attributes["href"].to_s] } | |
puts "- title: #{title}" | |
puts " date: #{date}" | |
puts " audio: #{audio[0]}" | |
puts " file_length: #{audio[1]}" | |
puts " duration: \"#{duration}\"" | |
puts " description: #{description}" | |
puts " links:" | |
puts links.map { |link| " - text: #{link[0]}\n href: #{link[1]}" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment