Class: Cherrypicker::Rapidshare

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PluginBase

inherited

Constructor Details

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

Returns a new instance of Rapidshare.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 14

def initialize(link, opts={})
  uri = URI.parse(link)

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

  @link     = link
  @username = o[:username]
  @password = o[:password]
  @fileid   = fileid
  @size     = o[:size]
  @location = o[:location]
  @filename = File.basename(uri.path)
  @hostname = hostname
  @download_url = @hostname + remote_url
end

Instance Attribute Details

#download_urlObject

Returns the value of attribute download_url.



8
9
10
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8

def download_url
  @download_url
end

#fileidObject

Returns the value of attribute fileid.



8
9
10
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8

def fileid
  @fileid
end

#filenameObject

Returns the value of attribute filename.



8
9
10
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8

def filename
  @filename
end

#hostnameObject

Returns the value of attribute hostname.



8
9
10
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8

def hostname
  @hostname
end

Returns the value of attribute link.



8
9
10
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8

def link
  @link
end

#locationObject

Returns the value of attribute location.



8
9
10
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8

def location
  @location
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8

def password
  @password
end

#sizeObject

Returns the value of attribute size.



8
9
10
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8

def size
  @size
end

#usernameObject

Returns the value of attribute username.



8
9
10
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8

def username
  @username
end

Class Method Details

.matches_provider?(url) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 10

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

Instance Method Details

#create_urlObject



47
48
49
50
51
52
53
54
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 47

def create_url
 Cherrypicker::hash_to_url({
    :fileid  =>   @fileid,
    :filename  => @filename,
    :login  =>    @username.to_s,
    :password  => @password.to_s,
  })
end

#downloadObject



35
36
37
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 35

def download
  Cherrypicker::download_file(@hostname + remote_url, :location => @location, :size => @size, :filename =>  @filename)
end

#remote_urlObject



43
44
45
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 43

def remote_url
  "/cgi-bin/rsapi.cgi?sub=download&" + create_url
end