Class: VgMetacafe

Inherits:
Object show all
Defined in:
lib/acts_as_unvlogable/vg_metacafe.rb

Instance Method Summary collapse

Constructor Details

#initialize(url = nil, options = {}) ⇒ VgMetacafe

Returns a new instance of VgMetacafe.



9
10
11
12
13
14
15
16
# File 'lib/acts_as_unvlogable/vg_metacafe.rb', line 9

def initialize(url=nil, options={})
  @url = url
  @args = parse_url(url)
  
  #is the video 'youtubed'?
  @youtubed = @args[1].index("yt-").nil? ? false : true
  @yt = @youtubed ? VgYoutube.new("http://www.youtube.com/watch?v=#{@args[1].sub('yt-', '')}") : nil
end

Instance Method Details

#download_urlObject



50
51
52
# File 'lib/acts_as_unvlogable/vg_metacafe.rb', line 50

def download_url
  nil
end

#durationObject



46
47
48
# File 'lib/acts_as_unvlogable/vg_metacafe.rb', line 46

def duration
  nil
end

#embed_html(width = 425, height = 344, options = {}) ⇒ Object



30
31
32
# File 'lib/acts_as_unvlogable/vg_metacafe.rb', line 30

def embed_html(width=425, height=344, options={})
  "<embed src='#{embed_url}' width='#{width}' height='#{height}' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>"
end

#embed_urlObject



26
27
28
# File 'lib/acts_as_unvlogable/vg_metacafe.rb', line 26

def embed_url
  "http://www.metacafe.com/fplayer/#{@args[1]}/#{@args[2]}.swf"
end

#flvObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/acts_as_unvlogable/vg_metacafe.rb', line 34

def flv
  if @youtubed
    @yt.flv
  else
    params = Hash.new
    open(self.embed_url) {|f|
      params = CGI::parse(f.base_uri.request_uri.split("?")[1])
    }
    CGI::unescape "#{ params['mediaURL']}?__gda__=#{params['gdaKey']}"
  end
end

#serviceObject



54
55
56
# File 'lib/acts_as_unvlogable/vg_metacafe.rb', line 54

def service
  "Metacafe"
end

#thumbnailObject



22
23
24
# File 'lib/acts_as_unvlogable/vg_metacafe.rb', line 22

def thumbnail
  "http://www.metacafe.com/thumb/#{@args[1]}.jpg"
end

#titleObject



18
19
20
# File 'lib/acts_as_unvlogable/vg_metacafe.rb', line 18

def title
  @youtubed ? @yt.title : (@args[2].humanize unless @args[2].blank?)
end