Class: Cherrypicker::Hotfile
- Inherits:
-
PluginBase
- Object
- PluginBase
- Cherrypicker::Hotfile
- Defined in:
- lib/cherrypicker/plugins/hotfile.rb
Instance Attribute Summary collapse
-
#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.
-
#query ⇒ Object
Returns the value of attribute query.
-
#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
- #download_url ⇒ Object
-
#initialize(link, opts = {}) ⇒ Hotfile
constructor
A new instance of Hotfile.
Methods inherited from PluginBase
Constructor Details
#initialize(link, opts = {}) ⇒ Hotfile
Returns a new instance of Hotfile.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 15 def initialize(link, opts={}) if link =~ /hotfile.com\/dl\/\d*\/[0-9a-f]*\/.*.*\.html/ @link = link[/(.*)\.html/, 1] #remove .html from link else @link = link end uri = URI.parse(@link) o = { :location => nil, :size => nil, :username => nil, :password => nil, }.merge(opts) @username = o[:username] @password = o[:password] @size = o[:size] @location = o[:location] @filename = File.basename(uri.path) end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
9 10 11 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 9 def filename @filename end |
#hostname ⇒ Object
Returns the value of attribute hostname.
9 10 11 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 9 def hostname @hostname end |
#link ⇒ Object
Returns the value of attribute link.
9 10 11 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 9 def link @link end |
#location ⇒ Object
Returns the value of attribute location.
9 10 11 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 9 def location @location end |
#password ⇒ Object
Returns the value of attribute password.
9 10 11 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 9 def password @password end |
#query ⇒ Object
Returns the value of attribute query.
9 10 11 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 9 def query @query end |
#size ⇒ Object
Returns the value of attribute size.
9 10 11 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 9 def size @size end |
#username ⇒ Object
Returns the value of attribute username.
9 10 11 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 9 def username @username end |
Class Method Details
.matches_provider?(url) ⇒ Boolean
11 12 13 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 11 def self.matches_provider?(url) url.include?("hotfile.com") end |
Instance Method Details
#create_url ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 42 def create_url Cherrypicker::hash_to_url({ :link => @link, :username => @username.to_s, :password => @password.to_s, }) end |
#download ⇒ Object
38 39 40 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 38 def download Cherrypicker::download_file(download_url, :location => @location, :size => @size, :filename => @filename) end |
#download_url ⇒ Object
50 51 52 |
# File 'lib/cherrypicker/plugins/hotfile.rb', line 50 def download_url Cherrypicker::remote_query("http://api.hotfile.com/?action=getdirectdownloadlink&" + create_url).response.body.gsub(/\n/,'') end |