Class: Cherrypicker::Googlevideo

Inherits:
PluginBase show all
Defined in:
lib/cherrypicker/plugins/googlevideo.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PluginBase

inherited

Constructor Details

#initialize(link, opts = {}) ⇒ Googlevideo

Returns a new instance of Googlevideo.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cherrypicker/plugins/googlevideo.rb', line 13

def initialize(link, opts={})

  o = {
    :location => nil,
  }.merge(opts)

  @link         = link
  @filename     = ""
  @location     = o[:location]
  @download_url = ""
  
  response = Cherrypicker::remote_query(@link)      
  @filename = response.body[/<title>(.*)<\/title>/, 1] + ".flv"
  @download_url = CGI.unescape(response.body[/videoUrl\\x3d(.*)\\x26thumbnailUrl/, 1])
end

Instance Attribute Details

#download_urlObject

Returns the value of attribute download_url.



7
8
9
# File 'lib/cherrypicker/plugins/googlevideo.rb', line 7

def download_url
  @download_url
end

#filenameObject

Returns the value of attribute filename.



7
8
9
# File 'lib/cherrypicker/plugins/googlevideo.rb', line 7

def filename
  @filename
end

Returns the value of attribute link.



7
8
9
# File 'lib/cherrypicker/plugins/googlevideo.rb', line 7

def link
  @link
end

#locationObject

Returns the value of attribute location.



7
8
9
# File 'lib/cherrypicker/plugins/googlevideo.rb', line 7

def location
  @location
end

Class Method Details

.matches_provider?(url) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/cherrypicker/plugins/googlevideo.rb', line 9

def self.matches_provider?(url)
  url.include?("video.google.com")
end

Instance Method Details

#downloadObject



29
30
31
# File 'lib/cherrypicker/plugins/googlevideo.rb', line 29

def download
  Cherrypicker::download_file(@download_url, :location => @location, :filename => @filename)
end