Permalink
Browse files

adding metacafe library

  • Loading branch information...
1 parent 80d0a21 commit be5b35c2970f4f38a37e3f306e7d64a9aed020ed @mamuso mamuso committed Dec 31, 2008
Showing with 78 additions and 13 deletions.
  1. +1 −1 MIT-LICENSE
  2. +1 −0 lib/vg_google.rb
  3. +67 −0 lib/vg_metacafe.rb
  4. +1 −0 lib/vg_youtube.rb
  5. +5 −5 lib/videogrinder.rb
  6. +0 −4 tasks/videogrinder_tasks.rake
  7. +3 −3 videogrinder_sample.yml
View
@@ -1,4 +1,4 @@
-Copyright (c) 2008 [name of plugin creator]
+Copyright (c) 2008 unvlog.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -1,5 +1,6 @@
# ----------------------------------------------
# Class for Google Video (video.google.com)
+# http://video.google.com/videoplay?docid=4798198171297333202&ei=Vq9aSeOmBYuGjQK-6Zy5CQ&q=pocoyo&hl=es
# ----------------------------------------------
View
@@ -0,0 +1,67 @@
+# ----------------------------------------------
+# Class for Metacafe (www.metacafe.com)
+# http://www.metacafe.com/watch/476621/experiments_with_the_myth_busters_with_diet_coke_and_mentos_dry/
+# ----------------------------------------------
+
+
+class VgMetacafe
+
+ def initialize(url=nil)
+ @url = url
+ @args = parse_url(url)
+ end
+
+ def title
+ @args[2].humanize unless @args[2].blank?
+ end
+
+ def thumbnail
+ "http://www.metacafe.com/thumb/#{@args[1]}.jpg"
+ end
+
+ def embed_url
+ "http://www.metacafe.com/fplayer/#{@args[1]}/#{@args[2]}.swf"
+ end
+
+ def embed_html(width=425, height=344, options={})
+ "<embed src='http://www.metacafe.com/fplayer/#{@args[1]}/#{@args[2]}.swf' width='#{width}' height='#{height}' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>"
+ end
+
+ def flv
+ params = Hash.new
+ open(self.embed_url) {|f|
+ params = get_hash f.base_uri.request_uri.split("?")[1]
+ }
+ "#{CGI::unescape params['mediaURL']}?__gda__=#{params['gdaKey']}"
+ end
+
+ private
+
+ def parse_url(url)
+ uri = URI.parse(url)
+ path = uri.path
+ @args = ''
+ if path and path.split("/").size >=1
+ @args = path.split("/")
+ @args.delete("watch")
+
+ raise unless @args.size > 0
+ else
+ raise
+ end
+ @args
+ rescue
+ nil
+ end
+
+ def get_hash(string)
+ hash = Hash.new
+ string.split("&").each do |elemement|
+ pieces = elemement.split("=")
+ hash[pieces[0]] = pieces[1]
+ end
+ hash.delete_if { |key, value| value.nil? }
+ end
+
+
+end
View
@@ -1,5 +1,6 @@
# ----------------------------------------------
# Class for Youtube (youtube.com)
+# http://www.youtube.com/watch?v=25AsfkriHQc
# ----------------------------------------------
View
@@ -5,23 +5,23 @@ def initialize(url=nil)
end
def title
- @object.title rescue {}
+ @object.title rescue ""
end
def thumbnail
- @object.thumbnail rescue {}
+ @object.thumbnail rescue ""
end
def embed_url
- @object.embed_url rescue {}
+ @object.embed_url rescue ""
end
def embed_html(width=425, height=344, options={})
- @object.embed_html(width, height, options) rescue {}
+ @object.embed_html(width, height, options) rescue ""
end
def flv
- @object.flv rescue {}
+ @object.flv rescue ""
end
def video_details
@@ -1,4 +0,0 @@
-# desc "Explaining what the task does"
-# task :videogrinder do
-# # Task goes here
-# end
View
@@ -1,12 +1,12 @@
# fill the gaps :)
#
#
-# youtube
+# youtube => http://code.google.com/intl/en-EN/apis/youtube/2.0/developers_guide_protocol.html#Developer_Key
youtube_key:
-# vimeo
+# vimeo => http://vimeo.com/api
vimeo_key:
vimeo_secret:
-# flickr
+# flickr =>
flickr_key:

0 comments on commit be5b35c

Please sign in to comment.