cherrypicker 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cherrypicker/functions.rb +29 -6
- data/lib/cherrypicker/hotfile.rb +0 -2
- data/lib/cherrypicker/rapidshare.rb +3 -5
- data/lib/cherrypicker/version.rb +1 -1
- data/lib/cherrypicker.rb +3 -2
- metadata +2 -2
@@ -1,16 +1,22 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
#The points are decremented by 1000 per minute. If you are able to parse the http header,
|
2
|
+
#you can parse "X-APICPU: x/y", where x stands for your current points
|
3
|
+
require 'net/http'
|
3
4
|
require 'open-uri'
|
4
5
|
|
5
|
-
def remote_query(url)
|
6
|
+
def remote_query(url)
|
6
7
|
begin
|
7
8
|
uri = URI.parse(url)
|
8
9
|
http = Net::HTTP.new(uri.host, uri.port)
|
9
|
-
http.open_timeout = 3 #
|
10
|
-
http.read_timeout = 3 #
|
10
|
+
http.open_timeout = 3 # seconds
|
11
|
+
http.read_timeout = 3 # seconds
|
11
12
|
request = Net::HTTP::Get.new(uri.request_uri)
|
12
|
-
request.initialize_http_header({"User-Agent" =>
|
13
|
+
request.initialize_http_header({"User-Agent" => random_agent})
|
13
14
|
response = http.request(request)
|
15
|
+
if response["X-APICPU"]
|
16
|
+
if (response["X-APICPU"][/(\d*)\/\d*/, 1]).to_i > 1000
|
17
|
+
sleep 60 # seconds
|
18
|
+
end
|
19
|
+
end
|
14
20
|
return response
|
15
21
|
rescue SocketError
|
16
22
|
$stderr.print "IO failed: " + $!
|
@@ -23,4 +29,21 @@ def hash_to_url(hash)
|
|
23
29
|
query_string << '&' unless key == hash.keys.first
|
24
30
|
query_string << "#{URI.encode(key.to_s)}=#{URI.encode(hash[key])}"
|
25
31
|
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Have a random Browser User Agent just incase
|
37
|
+
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
|
+
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)",
|
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/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"].sample
|
26
49
|
end
|
data/lib/cherrypicker/hotfile.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
# hotfile = Hotfile.new("http://hotfile.com/dl/110589431/6ad2666/ROT007-WEB-2011.rar.html", "username", "password")
|
4
4
|
# puts hotfile.link
|
5
5
|
# puts hotfile.hostname
|
6
|
-
require 'open-uri'
|
7
|
-
|
8
6
|
class Hotfile
|
9
7
|
attr_accessor :link, :hostname, :filename, :username, :password
|
10
8
|
|
@@ -5,9 +5,6 @@
|
|
5
5
|
# puts rapid.fileid
|
6
6
|
# puts rapid.filename
|
7
7
|
# puts rapid.host
|
8
|
-
require "net/http"
|
9
|
-
require "uri"
|
10
|
-
|
11
8
|
class Rapidshare
|
12
9
|
attr_accessor :link, :fileid, :filename, :hostname, :username, :password
|
13
10
|
|
@@ -48,5 +45,6 @@ class Rapidshare
|
|
48
45
|
def hostname
|
49
46
|
query = remote_query("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&" + create_url)
|
50
47
|
query.response.body[/DL:(.*).rapidshare.com/, 1] + ".rapidshare.com"
|
51
|
-
end
|
52
|
-
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
data/lib/cherrypicker/version.rb
CHANGED
data/lib/cherrypicker.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cherrypicker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Karl Entwistle
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-18 00:00:00 +00:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|