Class: VgVimeo

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of VgVimeo.



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

def initialize(url=nil, options={})
  # general settings
  @url = url
  @video_id = parse_url(url)
  res = Net::HTTP.get(URI.parse("http://vimeo.com/moogaloop/load/clip:#{@video_id}/embed?param_server=vimeo.com&param_clip_id=#{@video_id}"))
  @feed = REXML::Document.new(res)
end

Instance Method Details

#download_urlObject



47
48
49
50
51
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 47

def download_url
  request_signature = REXML::XPath.first( @feed, "//request_signature" )[0]
  request_signature_expires = REXML::XPath.first( @feed, "//request_signature_expires" )[0]
  "http://www.vimeo.com/moogaloop/play/clip:#{@video_id}/#{request_signature}/#{request_signature_expires}/?q=hd"
end

#durationObject



29
30
31
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 29

def duration
  REXML::XPath.first( @feed, "//duration" )[0].to_s.to_i
end

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



37
38
39
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 37

def embed_html(width=425, height=344, options={})
  "<object width='#{width}' height='#{height}'><param name='movie' value='#{embed_url}'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='#{embed_url}' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='#{width}' height='#{height}'></embed></object>"
end

#embed_urlObject



33
34
35
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 33

def embed_url
  "http://vimeo.com/moogaloop.swf?clip_id=#{@video_id}&server=vimeo.com&fullscreen=1&show_title=1&show_byline=1&show_portrait=1"
end

#flvObject



41
42
43
44
45
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 41

def flv
  request_signature = REXML::XPath.first( @feed, "//request_signature" )[0]
  request_signature_expires = REXML::XPath.first( @feed, "//request_signature_expires" )[0]
  "http://www.vimeo.com/moogaloop/play/clip:#{@video_id}/#{request_signature}/#{request_signature_expires}/"
end

#serviceObject



53
54
55
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 53

def service
  "Vimeo"
end

#thumbnailObject



25
26
27
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 25

def thumbnail
  REXML::XPath.first( @feed, "//thumbnail" )[0].to_s
end

#titleObject



21
22
23
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 21

def title
  REXML::XPath.first( @feed, "//caption" )[0].to_s
end

#video_idObject



17
18
19
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 17

def video_id
  @video_id
end