Class: Cherrypicker::Hotfile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Hotfile.



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

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

Instance Method Details

#create_urlObject



38
39
40
41
42
43
44
# File 'lib/cherrypicker/plugins/hotfile.rb', line 38

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

#downloadObject



34
35
36
# File 'lib/cherrypicker/plugins/hotfile.rb', line 34

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

#download_urlObject



46
47
48
# File 'lib/cherrypicker/plugins/hotfile.rb', line 46

def download_url
  Cherrypicker::remote_query("http://api.hotfile.com/?action=getdirectdownloadlink&" + create_url).response.body.gsub(/\n/,'')
end