Class: VgFlickr
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 = {}) ⇒ VgFlickr
constructor
A new instance of VgFlickr.
- #service ⇒ Object
- #thumbnail ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(url = nil, options = {}) ⇒ VgFlickr
Returns a new instance of VgFlickr.
9 10 11 12 13 14 15 16 |
# File 'lib/acts_as_unvlogable/vg_flickr.rb', line 9 def initialize(url=nil, ={}) # general settings @url = url @video_id = parse_url(url) settings ||= YAML.load_file(RAILS_ROOT + '/config/unvlogable.yml') rescue {} @details = Flickr::Photo.new(@video_id, .nil? || [:key].nil? ? settings['flickr_key'] : [:key]) raise if @details.media != "video" end |
Instance Method Details
#download_url ⇒ Object
48 49 50 |
# File 'lib/acts_as_unvlogable/vg_flickr.rb', line 48 def download_url nil end |
#duration ⇒ Object
52 53 54 |
# File 'lib/acts_as_unvlogable/vg_flickr.rb', line 52 def duration nil end |
#embed_html(width = 425, height = 344, options = {}) ⇒ Object
30 31 32 |
# File 'lib/acts_as_unvlogable/vg_flickr.rb', line 30 def (width=425, height=344, ={}) "<object type='application/x-shockwave-flash' width='#{width}' height='#{height}' data='http://www.flickr.com/apps/video/stewart.swf?v=63881' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'><param name='movie' value='#{}'></param> <param name='bgcolor' value='#000000'></param> <param name='allowFullScreen' value='true'></param><embed type='application/x-shockwave-flash' src='#{}' bgcolor='#000000' allowfullscreen='true' width='#{width}' height='#{height}'></embed></object>" end |
#embed_url ⇒ Object
26 27 28 |
# File 'lib/acts_as_unvlogable/vg_flickr.rb', line 26 def "http://www.flickr.com/apps/video/stewart.swf?v=63881&intl_lang=en-us&photo_secret=#{@details.secret}&photo_id=#{@video_id}" end |
#flv ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/acts_as_unvlogable/vg_flickr.rb', line 35 def flv player_feed = "http://www.flickr.com/apps/video/video_mtl_xml.gne?v=x&photo_id=#{@video_id}&secret=#{@details.secret}&olang=en-us&noBuffer=null&bitrate=700&target=_blank" res = Net::HTTP.get(URI::parse(player_feed)) player_feed_xml = REXML::Document.new(res) data_id = REXML::XPath.first(player_feed_xml, "//Data/Item[@id='id']")[0].to_s video_feed = "http://www.flickr.com/video_playlist.gne?node_id=#{data_id}&tech=flash&mode=playlist&lq=j2CW2jbpqCLKRy_s4bTylH&bitrate=700&secret=#{@details.secret}&rd=video.yahoo.com-offsite&noad=1" res = Net::HTTP.get(URI::parse(video_feed)) video_feed_xml = REXML::Document.new(res) stream = REXML::XPath.first(video_feed_xml, "//DATA/SEQUENCE-ITEM/STREAM") "#{stream.attributes['APP']}#{stream.attributes['FULLPATH']}" end |
#service ⇒ Object
56 57 58 |
# File 'lib/acts_as_unvlogable/vg_flickr.rb', line 56 def service "Flickr" end |
#thumbnail ⇒ Object
22 23 24 |
# File 'lib/acts_as_unvlogable/vg_flickr.rb', line 22 def thumbnail @details.source('Small') end |
#title ⇒ Object
18 19 20 |
# File 'lib/acts_as_unvlogable/vg_flickr.rb', line 18 def title @details.title end |