Skip to content

Instantly share code, notes, and snippets.

@tmtysk
Created October 15, 2009 08:37
Show Gist options
  • Save tmtysk/210786 to your computer and use it in GitHub Desktop.
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.
# 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
@murimig
Copy link

murimig commented May 1, 2018

I would like to know what the page is all about, thanks for your help and support.

@ziaS26
Copy link

ziaS26 commented Oct 10, 2021

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