Class: YouTube

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/you_tube.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ YouTube

Returns a new instance of YouTube.



7
8
9
10
11
# File 'lib/you_tube.rb', line 7

def initialize(obj)
  @clip_id   = obj.video_url.split('?v=').last
  @embed_url = "http://www.youtube.com/v/#{@clip_id}&hl=en&fs=1"
  @response  = self.class.get("/feeds/api/videos/#{@clip_id}")
end

Instance Method Details

#embed_htmlObject



17
18
19
20
21
22
23
24
25
# File 'lib/you_tube.rb', line 17

def embed_html
  <<-END
    <object width="425" height="344">
      <param name="movie" value="#{@embed_url}" />
      <param name="allowFullScreen" value="true" />
      <embed src="#{@embed_url}" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344" />
    </object>
  END
end

#thumbnail_urlObject



13
14
15
# File 'lib/you_tube.rb', line 13

def thumbnail_url
  @response["entry"]["media:group"]["media:thumbnail"][0]["url"]
end