Class: VgDailymotion
Instance Method Summary collapse
- #download_url ⇒ Object
- #duration ⇒ Object
- #embed_html(width = 425, height = 344, options = {}) ⇒ Object
- #embed_url ⇒ Object
- #flv ⇒ Object
-
#initialize(url = nil, options = {}) ⇒ VgDailymotion
constructor
A new instance of VgDailymotion.
- #service ⇒ Object
- #thumbnail ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(url = nil, options = {}) ⇒ VgDailymotion
Returns a new instance of VgDailymotion.
9 10 11 12 13 14 |
# File 'lib/acts_as_unvlogable/vg_dailymotion.rb', line 9 def initialize(url=nil, ={}) @url = url @video_id = parse_url(url) res = Net::HTTP.get(URI.parse("http://www.dailymotion.com/rss/video/#{@video_id}")) @feed = REXML::Document.new(res) end |
Instance Method Details
#download_url ⇒ Object
36 37 38 |
# File 'lib/acts_as_unvlogable/vg_dailymotion.rb', line 36 def download_url nil end |
#duration ⇒ Object
40 41 42 |
# File 'lib/acts_as_unvlogable/vg_dailymotion.rb', line 40 def duration nil end |
#embed_html(width = 425, height = 344, options = {}) ⇒ Object
28 29 30 |
# File 'lib/acts_as_unvlogable/vg_dailymotion.rb', line 28 def (width=425, height=344, ={}) "<object width='#{width}' height='#{height}'><param name='movie' value='#{}&related=1'></param><param name='allowFullScreen' value='true'></param><param name='allowScriptAccess' value='always'></param><embed src='#{}&related=1' type='application/x-shockwave-flash' width='#{width}' height='#{height}' allowFullScreen='true' allowScriptAccess='always'></embed></object>" end |
#embed_url ⇒ Object
24 25 26 |
# File 'lib/acts_as_unvlogable/vg_dailymotion.rb', line 24 def REXML::XPath.first(@feed, "//media:content[@type='application/x-shockwave-flash']").attributes['url'] end |
#flv ⇒ Object
32 33 34 |
# File 'lib/acts_as_unvlogable/vg_dailymotion.rb', line 32 def flv REXML::XPath.first(@feed, "//media:content[@type='video/x-flv']").attributes['url'] end |
#service ⇒ Object
44 45 46 |
# File 'lib/acts_as_unvlogable/vg_dailymotion.rb', line 44 def service "Dailymotion" end |
#thumbnail ⇒ Object
20 21 22 |
# File 'lib/acts_as_unvlogable/vg_dailymotion.rb', line 20 def thumbnail REXML::XPath.first(@feed, "//media:thumbnail").attributes['url'].gsub("preview_large", "preview_medium") end |
#title ⇒ Object
16 17 18 |
# File 'lib/acts_as_unvlogable/vg_dailymotion.rb', line 16 def title REXML::XPath.first(@feed, "//item/title")[0].to_s end |