cherrypicker 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +13 -0
- data/lib/cherrypicker/functions.rb +3 -0
- data/lib/cherrypicker/linkchecker.rb +107 -0
- data/lib/cherrypicker/version.rb +2 -2
- data/lib/cherrypicker.rb +1 -0
- metadata +3 -2
data/README
CHANGED
@@ -20,6 +20,19 @@
|
|
20
20
|
test2 = Hotfile.new("http://hotfile.com/dl/81103855/ee51a52/myfile.rar", "username", "password")
|
21
21
|
test2.download
|
22
22
|
|
23
|
+
check = LinkChecker.new([
|
24
|
+
"http://rapidshare.com/files/329036215/myfile.rar",
|
25
|
+
"http://rapidshare.com/files/329036764/deadfile.rar"]).status
|
26
|
+
|
27
|
+
p check
|
28
|
+
|
29
|
+
{"Alive"=>["http://rapidshare.com/files/453469831/Playaz-Sub_Zero-PLAYAZ015-WEB-2011-EGM.rar"], "Dead"=>["http://rapidshare.com/files/329036764/deadfile.rar"]}
|
30
|
+
|
31
|
+
check = LinkChecker.new([
|
32
|
+
"http://hotfile.com/dl/111044909/8410b57/Playaz-Sub_Zero-PLAYAZ015-WEB-2011-EGM.rar.html",
|
33
|
+
"http://hotfile.com/dl/111044200/3eb1174/Flux_Pavilion-Bass_Cannon-WEB-2011.rar.html"]).status
|
34
|
+
|
35
|
+
|
23
36
|
== Limitations
|
24
37
|
|
25
38
|
This is only useful if you're using premium accounts, this will not work without a valid username and password when downloading a file
|
@@ -45,5 +45,8 @@ def random_agent
|
|
45
45
|
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Win64; x64; Trident/4.0)",
|
46
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
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",
|
48
51
|
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"].sample
|
49
52
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
class LinkChecker
|
2
|
+
attr_accessor :links, :status
|
3
|
+
|
4
|
+
def initialize(links)
|
5
|
+
@links = links
|
6
|
+
if links.sample =~ /^http:\/\/rapidshare.com/
|
7
|
+
@status = rapidshare
|
8
|
+
else
|
9
|
+
@status = hotfile
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def rapidshare
|
14
|
+
files = Array.new
|
15
|
+
filenames = Array.new
|
16
|
+
singlelinks = Array.new
|
17
|
+
|
18
|
+
self.links.each do |link|
|
19
|
+
files << link[/files\/(\d*)\//, 1]
|
20
|
+
filenames << link[/files\/\d*\/(.*)/, 1]
|
21
|
+
end
|
22
|
+
|
23
|
+
query = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles&" +
|
24
|
+
hash_to_url({
|
25
|
+
files: files.join(","),
|
26
|
+
filenames: filenames.join(","),
|
27
|
+
incmd5: '0'
|
28
|
+
})
|
29
|
+
|
30
|
+
check = remote_query(query).body.split("\n")
|
31
|
+
|
32
|
+
#"452966383,ROT007-WEB-2011.rar,23635847,23,1,tl2,0"
|
33
|
+
check.each_with_index do |c, index|
|
34
|
+
c[/([^,]+)\,([^,]+)\,([^,]+)\,([^,]+)\,([^,]+)\,([^,]+)\,([^,]+)/]
|
35
|
+
size = Regexp.last_match(3)
|
36
|
+
if Regexp.last_match(5) == "1"
|
37
|
+
status = "Alive"
|
38
|
+
else
|
39
|
+
status = "Dead"
|
40
|
+
end
|
41
|
+
singlelinks << SingleLink.new(links[index], "#{status}")
|
42
|
+
end
|
43
|
+
|
44
|
+
links = {}
|
45
|
+
singlelinks.each do |a|
|
46
|
+
links[a.status] ||= []
|
47
|
+
links[a.status] << a.link
|
48
|
+
end
|
49
|
+
|
50
|
+
return links
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def hotfile
|
55
|
+
links = self.links
|
56
|
+
ids = Array.new
|
57
|
+
keys = Array.new
|
58
|
+
singlelinks = Array.new
|
59
|
+
|
60
|
+
links.each do |link|
|
61
|
+
link[/http\:\/\/hotfile\.com\/dl\/([^\/]+)\/([^\/]+)\/([^\/]+)/]
|
62
|
+
ids << Regexp.last_match(1)
|
63
|
+
keys << Regexp.last_match(2)
|
64
|
+
end
|
65
|
+
|
66
|
+
query = "http://api.hotfile.com/?action=checklinks&" +
|
67
|
+
hash_to_url({
|
68
|
+
links: links.join(","),
|
69
|
+
id: ids.join(","),
|
70
|
+
keys: keys.join(","),
|
71
|
+
files: "id,status,size"
|
72
|
+
})
|
73
|
+
|
74
|
+
check = remote_query(query).body.split("\n")
|
75
|
+
|
76
|
+
#"111044909,1,Playaz-Sub_Zero-PLAYAZ015-WEB-2011-EGM.rar "
|
77
|
+
check.each_with_index do |c, index|
|
78
|
+
c[/([^,]+)\,([^,]+)\,([^,]+)/]
|
79
|
+
name = Regexp.last_match(3)
|
80
|
+
size = Regexp.last_match(1)
|
81
|
+
if Regexp.last_match(2) == "1"
|
82
|
+
status = "Alive"
|
83
|
+
else
|
84
|
+
status = "Dead"
|
85
|
+
end
|
86
|
+
singlelinks << SingleLink.new(links[index], "#{status}")
|
87
|
+
end
|
88
|
+
|
89
|
+
links = {}
|
90
|
+
singlelinks.each do |a|
|
91
|
+
links[a.status] ||= []
|
92
|
+
links[a.status] << a.link
|
93
|
+
end
|
94
|
+
|
95
|
+
return links
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class SingleLink
|
101
|
+
attr_accessor :link, :status
|
102
|
+
|
103
|
+
def initialize(link, status)
|
104
|
+
@link = link
|
105
|
+
@status = status
|
106
|
+
end
|
107
|
+
end
|
data/lib/cherrypicker/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Cherrypicker
|
2
|
-
VERSION = "0.0
|
3
|
-
end
|
2
|
+
VERSION = "0.1.0"
|
3
|
+
end
|
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.1.0
|
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-20 00:00:00 +00:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- lib/cherrypicker/download.rb
|
34
34
|
- lib/cherrypicker/functions.rb
|
35
35
|
- lib/cherrypicker/hotfile.rb
|
36
|
+
- lib/cherrypicker/linkchecker.rb
|
36
37
|
- lib/cherrypicker/rapidshare.rb
|
37
38
|
- lib/cherrypicker/version.rb
|
38
39
|
- test/test_helper.rb
|