class Humpyard::Assets::YoutubeAsset
Public Instance Methods
content_type()
click to toggle source
# File app/models/humpyard/assets/youtube_asset.rb 19 def content_type 20 'video/youtube' 21 end
title()
click to toggle source
# File app/models/humpyard/assets/youtube_asset.rb 15 def title 16 youtube_title || "YouTube #{youtube_video_id}" 17 end
update_youtube_data()
click to toggle source
# File app/models/humpyard/assets/youtube_asset.rb 23 def update_youtube_data 24 begin 25 require 'net/http' 26 27 xml = Net::HTTP.get_response(URI.parse("http://gdata.youtube.com/feeds/api/videos/#{youtube_video_id}")).body 28 29 title = xml.force_encoding("UTF-8").scan(/<title.*>(.+?)<\/title>/).first.first 30 31 self.youtube_title = title 32 rescue 33 self.youtube_title = "YouTube #{youtube_video_id}" 34 end 35 end
url()
click to toggle source
# File app/models/humpyard/assets/youtube_asset.rb 11 def url 12 "http://www.youtube.com/watch?v=#{youtube_video_id}" 13 end