Class: VgQik

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of VgQik.



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

def initialize(url=nil, options={})
  @url = url
  @video_id = parse_url(url)
  @page = Hpricot(open("http://qik.com/video/#{@video_id}"))
  emb = @page.search('//input[@value^="<object"]').first.attributes['value']
  tx = Hpricot(emb)
  @feed_url =  CGI::parse(tx.search('//embed').first.attributes['flashvars'].to_s)["rssURL"].to_s
  res =  Net::HTTP.get(URI::parse(@feed_url))
  @feed = REXML::Document.new(res)
end

Instance Method Details

#download_urlObject



40
41
42
# File 'lib/acts_as_unvlogable/vg_qik.rb', line 40

def download_url
  nil
end

#durationObject



44
45
46
# File 'lib/acts_as_unvlogable/vg_qik.rb', line 44

def duration
  nil
end

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



32
33
34
# File 'lib/acts_as_unvlogable/vg_qik.rb', line 32

def embed_html(width=425, height=344, options={})
  "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='#{width}' height='#{height}' id='qikPlayer' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='true' /><param name='movie' value='#{embed_url}' /><param name='quality' value='high' /><param name='bgcolor' value='#333333' /><embed src='#{embed_url}' quality='high' bgcolor='#333333' width='#{width}' height='#{height}' name='qikPlayer' align='middle' allowScriptAccess='sameDomain' allowFullScreen='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'/></object>"
end

#embed_urlObject



28
29
30
# File 'lib/acts_as_unvlogable/vg_qik.rb', line 28

def embed_url
  "http://qik.com/swfs/qikPlayer4.swf?rssURL=#{@feed_url}&autoPlay=false"
end

#flvObject



36
37
38
# File 'lib/acts_as_unvlogable/vg_qik.rb', line 36

def flv
  REXML::XPath.first(@feed, "//item/media:content[@type='video/x-flv']").attributes['url']
end

#serviceObject



48
49
50
# File 'lib/acts_as_unvlogable/vg_qik.rb', line 48

def service
  "Qik"
end

#thumbnailObject



24
25
26
# File 'lib/acts_as_unvlogable/vg_qik.rb', line 24

def thumbnail
  REXML::XPath.first(@feed, "//item/media:thumbnail").attributes['url']
end

#titleObject



20
21
22
# File 'lib/acts_as_unvlogable/vg_qik.rb', line 20

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