class Humpyard::Assets::YoutubeAsset

Public Instance Methods

content_type() click to toggle source
# File app/models/humpyard/assets/youtube_asset.rb, line 19
def content_type
  'video/youtube'
end
title() click to toggle source
# File app/models/humpyard/assets/youtube_asset.rb, line 15
def title
  youtube_title || "YouTube #{youtube_video_id}"
end
update_youtube_data() click to toggle source
# File app/models/humpyard/assets/youtube_asset.rb, line 23
def update_youtube_data
  begin
    require 'net/http'

    xml = Net::HTTP.get_response(URI.parse("http://gdata.youtube.com/feeds/api/videos/#{youtube_video_id}")).body

    title = xml.force_encoding("UTF-8").scan(/<title.*>(.+?)<\/title>/).first.first
  
    self.youtube_title = title
  rescue
    self.youtube_title = "YouTube #{youtube_video_id}"
  end
end
url() click to toggle source
# File app/models/humpyard/assets/youtube_asset.rb, line 11
def url
  "http://www.youtube.com/watch?v=#{youtube_video_id}"
end