Created
February 23, 2011 22:29
-
-
Save photomattmills/841337 to your computer and use it in GitHub Desktop.
simple script to convert an RSS feed to jekyll files.
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
# from the standard library : | |
require 'rss/1.0' | |
require 'rss/2.0' | |
require 'open-uri' | |
require 'time' | |
# gem install to_slug if you don't have it already. | |
require 'to_slug' | |
source = "" # put your feed url here | |
content = "" # this is just initializing the string | |
open(source) do |s| content = s.read end | |
rss = RSS::Parser.parse(content, false) | |
rss.items.each do |item| | |
filename = "#{item.date.strftime("%Y-%m-%d")}-#{item.title.to_slug.sub(/-\Z/,"")}.html" | |
file = File.new(filename, "w+") | |
file.puts "---\nlayout: post\ntitle: #{item.title}\ndate: #{item.date.strftime("%Y-%m-%d")}\n---\n#{item.description}" | |
file.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment