Class: Thumbnailer::VideoGoogle

Inherits:
Base
  • Object
show all
Defined in:
lib/thumbnailer/sites/video_google.rb

Instance Attribute Summary

Attributes inherited from Base

#embed_url, #small_thumb_image, #thumb_image

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ VideoGoogle

Returns a new instance of VideoGoogle.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/thumbnailer/sites/video_google.rb', line 3

def initialize(uri)
  begin
    params = CGI.parse(uri.query)
    doc = open("http://video.google.com/videofeed?docid=#{params['docid']}").read
#        @thumb_image = CGI.unescape(doc.scan(/thumbnailUrl\\x3d(.*?)\\x26/im)[0][0].gsub(/http:\/\/(\d+).*?/, "http://2"))
    doc = XML::Parser.string(doc).parse.find("//channel/item/media:group/media:thumbnail")

    @thumb_image = doc[0]['url']
    @small_thumb_image = @thumb_image
    @embed_url = "#{uri.scheme}://#{uri.host}/googleplayer.swf?docId=#{params['docid']}"
  rescue
  end
end