cherrypicker 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,10 @@
|
|
1
1
|
# Class that can download files from cyberlockers
|
2
2
|
#
|
3
|
-
# Download.new(hostname, url,
|
3
|
+
# Download.new(hostname, url, size, password)
|
4
4
|
require 'net/http'
|
5
|
+
require 'net/https'
|
5
6
|
require 'progressbar'
|
7
|
+
require 'open-uri'
|
6
8
|
|
7
9
|
class Download
|
8
10
|
attr_accessor :hostname, :url, :filename, :size, :progress, :location
|
@@ -14,15 +16,17 @@ class Download
|
|
14
16
|
@size = size
|
15
17
|
@location = location
|
16
18
|
@progress = 0
|
17
|
-
|
19
|
+
|
18
20
|
download_file
|
19
21
|
end
|
20
|
-
|
21
|
-
private
|
22
22
|
|
23
23
|
def download_file
|
24
|
-
|
25
|
-
http.
|
24
|
+
uri = URI.parse("#{self.hostname}" + "#{self.url}")
|
25
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
26
|
+
http.use_ssl = true if uri.scheme == "https"
|
27
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
28
|
+
request.initialize_http_header({"User-Agent" => random_agent})
|
29
|
+
http.request(request) do |response|
|
26
30
|
bar = ProgressBar.new("#{self.filename}", self.size.to_i)
|
27
31
|
File.open("#{self.location}" + "#{self.filename}", "wb") do |file|
|
28
32
|
response.read_body do |segment|
|
@@ -1,12 +1,14 @@
|
|
1
1
|
#The points are decremented by 1000 per minute. If you are able to parse the http header,
|
2
2
|
#you can parse "X-APICPU: x/y", where x stands for your current points
|
3
3
|
require 'net/http'
|
4
|
+
require 'net/https'
|
4
5
|
require 'open-uri'
|
5
6
|
|
6
7
|
def remote_query(url)
|
7
8
|
begin
|
8
9
|
uri = URI.parse(url)
|
9
10
|
http = Net::HTTP.new(uri.host, uri.port)
|
11
|
+
http.use_ssl = true if uri.scheme == "https"
|
10
12
|
http.open_timeout = 3 # seconds
|
11
13
|
http.read_timeout = 3 # seconds
|
12
14
|
request = Net::HTTP::Get.new(uri.request_uri)
|
@@ -31,24 +33,7 @@ def hash_to_url(hash)
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
private
|
35
|
-
|
36
|
-
# Have a random Browser User Agent just incase
|
37
36
|
def random_agent
|
38
|
-
@useragent = ["Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090913 Firefox/3.5.3"
|
39
|
-
|
40
|
-
"Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)",
|
41
|
-
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.1) Gecko/20090718 Firefox/3.5.1",
|
42
|
-
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.1 (KHTML, like Gecko) Chrome/4.0.219.6 Safari/532.1",
|
43
|
-
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)",
|
44
|
-
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30729)",
|
45
|
-
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Win64; x64; Trident/4.0)",
|
46
|
-
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; .NET CLR 2.0.50727; InfoPath.2)Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)",
|
47
|
-
"Mozilla/4.0 (compatible; MSIE 6.1; Windows XP)",
|
48
|
-
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16",
|
49
|
-
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
|
50
|
-
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16",
|
51
|
-
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
|
52
|
-
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14"]
|
53
|
-
@useragent[rand(14)]
|
37
|
+
@useragent = ["Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090913 Firefox/3.5.3"]
|
38
|
+
return @useragent[0]
|
54
39
|
end
|
@@ -13,7 +13,7 @@ class Rapidshare
|
|
13
13
|
@link = link
|
14
14
|
@fileid = fileid
|
15
15
|
@filename = filename
|
16
|
-
|
16
|
+
@hostname = hostname
|
17
17
|
@username = username
|
18
18
|
@password = password
|
19
19
|
@size = size
|
@@ -47,6 +47,6 @@ class Rapidshare
|
|
47
47
|
|
48
48
|
def hostname
|
49
49
|
query = remote_query("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&" + create_url)
|
50
|
-
query.response.response["Location"][/
|
50
|
+
query.response.response["Location"][/(.*).rapidshare.com/, 1] + ".rapidshare.com"
|
51
51
|
end
|
52
52
|
end
|
data/lib/cherrypicker/version.rb
CHANGED