Permalink
Browse files

Revert "can't do youtube and vimeo enclosures until can get content l…

…ength"

This reverts commit ed0acee.
  • Loading branch information...
1 parent ed0acee commit b560422a6382a9c3346b720a1145d12c9967ca2d @mmb committed Sep 7, 2011
@@ -16,6 +16,8 @@ def self.up
# populate
require './plugins/add_pre_55_enclosure_self.rb'
+ require './plugins/add_pre_55_enclosure_vimeo.rb'
+ require './plugins/add_pre_55_enclosure_youtube.rb'
Murlsh::Url.find(:all).each do |u|
Murlsh::Plugin.hooks('add_pre') { |p| p.run u, {} }
@@ -0,0 +1,24 @@
+require 'murlsh'
+
+module Murlsh
+
+ # Create video enclosures for Vimeo urls.
+ class AddPre55EnclosureVimeo < Plugin
+
+ @hook = 'add_pre'
+
+ VimeoRe = %r{^http://(?:www\.)?vimeo\.com/(\d+)$}i
+
+ def self.run(url, config)
+ if match = VimeoRe.match(url.url)
+ url.enclosures.build(
+ :title => url.title,
+ :content_type => 'application/x-shockwave-flash',
+ :enclosure_url =>
+ "http://vimeo.com/moogaloop.swf?clip_id=#{match[1]}")
+ end
+ end
+
+ end
+
+end
@@ -0,0 +1,24 @@
+require 'murlsh'
+
+module Murlsh
+
+ # Create video enclosures for YouTube urls.
+ class AddPre55EnclosureYoutube < Plugin
+
+ @hook = 'add_pre'
+
+ YoutubeRe =
+ %r{^http://(?:(?:www|uk)\.)?youtube\.com/watch\?v=([\w\-]+)(?:&|$)}i
+
+ def self.run(url, config)
+ if match = YoutubeRe.match(url.url)
+ url.enclosures.build(
+ :title => url.title,
+ :content_type => 'application/x-shockwave-flash',
+ :enclosure_url => "http://www.youtube.com/v/#{match[1]}.swf")
+ end
+ end
+
+ end
+
+end

0 comments on commit b560422

Please sign in to comment.