Class: Cherrypicker::Hotfile

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PluginBase

inherited

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

#filenameObject

Returns the value of attribute filename.



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

def filename
  @filename
end

#hostnameObject

Returns the value of attribute hostname.



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

def hostname
  @hostname
end

Returns the value of attribute link.



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

def link
  @link
end

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#passwordObject

Returns the value of attribute password.



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

def password
  @password
end

#queryObject

Returns the value of attribute query.



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

def query
  @query
end

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end

#usernameObject

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

Returns:

  • (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_urlObject



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

#downloadObject



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_urlObject



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