Created
October 15, 2009 08:37
-
-
Save tmtysk/210786 to your computer and use it in GitHub Desktop.
Creating simple "Media RSS (http://video.search.yahoo.com/mrss)" from jpegs in specified directories and uri.
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
# mediarssgen.rb | |
# Creating simple "Media RSS (http://video.search.yahoo.com/mrss)" | |
# from jpegs in specified directories and uri. | |
# | |
# Usage: $ ruby mediarssgen.rb <thumbnail_dir> <image_dir> <uri_root> | |
require 'rubygems' | |
require 'libxml' | |
include LibXML | |
xml =<<EOS | |
<?xml version="1.0" encoding="utf-8" standalone="yes"?> | |
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" | |
xmlns:atom="http://www.w3.org/2005/Atom"> | |
</rss> | |
EOS | |
libxml = XML::Document.string(xml) | |
root = libxml.root | |
root << channel = XML::Node.new('channel') | |
Dir.glob("#{Dir.pwd}/#{ARGV[0]}/*.jpg") do |jpeg| | |
channel << item = XML::Node.new('item') | |
item << XML::Node.new('title', 'title sample') | |
item << XML::Node.new('media:description', 'description sample') | |
item << XML::Node.new('link', "#{ARGV[2]}/#{ARGV[1]}/#{File.basename(jpeg)}") | |
item << thumbnail = XML::Node.new('media:thumbnail') | |
thumbnail['url'] = "#{ARGV[2]}/#{ARGV[0]}/#{File.basename(jpeg)}" | |
item << content = XML::Node.new('media:content') | |
content['url'] = "#{ARGV[2]}/#{ARGV[1]}/#{File.basename(jpeg)}" | |
end | |
puts libxml.to_s(:indent => true) | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to know what the page is all about, thanks for your help and support.