Class: Cherrypicker::Rapidshare
- Inherits:
-
PluginBase
- Object
- PluginBase
- Cherrypicker::Rapidshare
- Defined in:
- lib/cherrypicker/plugins/rapidshare.rb
Instance Attribute Summary collapse
-
#download_url ⇒ Object
Returns the value of attribute download_url.
-
#fileid ⇒ Object
Returns the value of attribute fileid.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#link ⇒ Object
Returns the value of attribute link.
-
#location ⇒ Object
Returns the value of attribute location.
-
#password ⇒ Object
Returns the value of attribute password.
-
#size ⇒ Object
Returns the value of attribute size.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #create_url ⇒ Object
- #download ⇒ Object
-
#initialize(link, opts = {}) ⇒ Rapidshare
constructor
A new instance of Rapidshare.
- #remote_url ⇒ Object
Methods inherited from PluginBase
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_url ⇒ Object
Returns the value of attribute download_url.
8 9 10 |
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8 def download_url @download_url end |
#fileid ⇒ Object
Returns the value of attribute fileid.
8 9 10 |
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8 def fileid @fileid end |
#filename ⇒ Object
Returns the value of attribute filename.
8 9 10 |
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8 def filename @filename end |
#hostname ⇒ Object
Returns the value of attribute hostname.
8 9 10 |
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8 def hostname @hostname end |
#link ⇒ Object
Returns the value of attribute link.
8 9 10 |
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8 def link @link end |
#location ⇒ Object
Returns the value of attribute location.
8 9 10 |
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8 def location @location end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8 def password @password end |
#size ⇒ Object
Returns the value of attribute size.
8 9 10 |
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 8 def size @size end |
#username ⇒ Object
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
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_url ⇒ Object
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 |
#download ⇒ Object
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_url ⇒ Object
43 44 45 |
# File 'lib/cherrypicker/plugins/rapidshare.rb', line 43 def remote_url "/cgi-bin/rsapi.cgi?sub=download&" + create_url end |