cherrypicker 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ Cherrypicker
2
+ =========
3
+
4
+ Cherrypicker was part of my final year project for university it
5
+ is a Ruby Gem that lets you download from; Rapidshare or Hotfile
6
+ You can also utilise the LinkChecker to see if your files are
7
+ alive on Rapidshare or Hotfile
8
+
9
+ Enjoy!
10
+
11
+ Installation
12
+ ------------
13
+
14
+ gem install cherrypicker
15
+
16
+ Usage
17
+ -----
18
+
19
+ require 'cherrypicker'
20
+
21
+ Examples
22
+ --------
23
+
24
+ test = Rapidshare.new("http://rapidshare.com/files/329036215/myfile.rar", "username", "password")
25
+ test.download
26
+
27
+ test2 = Hotfile.new("http://hotfile.com/dl/81103855/ee51a52/myfile.rar", "username", "password")
28
+ test2.download
29
+
30
+ check = LinkChecker.new([
31
+ "http://rapidshare.com/files/329036215/myfile.rar",
32
+ "http://rapidshare.com/files/329036764/deadfile.rar"]).status
33
+
34
+ Contributing
35
+ ------------
36
+
37
+ If you'd like to contribute a feature or bugfix: Thanks! To make sure your
38
+ fix/feature has a high chance of being included, please read the following
39
+ guidelines:
40
+
41
+ 1. Post a new GitHub Issue[http://github.com/karlentwistle/Cherrypicker/issues].
42
+
43
+ Limitations
44
+ -----------
45
+
46
+ 1. The download function is only useful if you're using premium accounts,
47
+ this will not work without a valid username and password when downloading a file
48
+
49
+ 2. The linkchecker is subject to throttling from both Hotfile and Rapidshare
50
+ so don't abuse it
51
+
52
+ 3. I frequently have problems accessing file hosting sites because one of their
53
+ files has been included on the IWF list and the ISP IWF filtering screws things up.
54
+ (Im on Virgin Media)
55
+
56
+ License
57
+ -------
58
+
59
+ Cherypicker is free software, and may be redistributed and be used for
60
+ anything apart from the operation of nuclear facilities, aircraft navigation
61
+ or communication systems, air traffic control, life support or weapons systems.
@@ -1,3 +1,12 @@
1
+ # Class that can query Rapidshare or Hotfile to get link
2
+ #
3
+ # rapid = Rapidshare.new("http://rapidshare.com/files/329036215/The.Matrix.bandaa25.part06.rar", "username", "password")
4
+ # puts rapid.link
5
+ # puts rapid.fileid
6
+ # puts rapid.filename
7
+ # puts rapid.host
8
+ # rapid.download
9
+
1
10
  class LinkChecker
2
11
  attr_accessor :links, :status
3
12
 
@@ -11,6 +20,7 @@ class LinkChecker
11
20
  end
12
21
 
13
22
  def rapidshare
23
+ links = self.links
14
24
  files = Array.new
15
25
  filenames = Array.new
16
26
  singlelinks = Array.new
@@ -38,17 +48,15 @@ class LinkChecker
38
48
  else
39
49
  status = "Dead"
40
50
  end
41
- singlelinks << SingleLink.new(links[index], "#{status}")
51
+ singlelinks << SingleLink.new(links[index], "#{status}", size)
42
52
  end
43
53
 
44
54
  links = {}
45
55
  singlelinks.each do |a|
46
56
  links[a.status] ||= []
47
- links[a.status] << a.link
57
+ links[a.status] << [a.link, a.size]
48
58
  end
49
-
50
- return links
51
-
59
+ return links
52
60
  end
53
61
 
54
62
  def hotfile
@@ -73,34 +81,39 @@ class LinkChecker
73
81
 
74
82
  check = remote_query(query).body.split("\n")
75
83
 
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"
84
+ unless check.size == 0
85
+ #"111044909,1,Playaz-Sub_Zero-PLAYAZ015-WEB-2011-EGM.rar "
86
+ check.each_with_index do |c, index|
87
+ c[/([^,]+)\,([^,]+)\,([^,]+)/]
88
+ name = Regexp.last_match(3)
89
+ size = Regexp.last_match(1)
90
+ if Regexp.last_match(2) == "1"
91
+ status = "Alive"
92
+ else
93
+ status = "Dead"
94
+ end
95
+ singlelinks << SingleLink.new(links[index], "#{status}", size)
96
+ end
97
+ else
98
+ links.each do |link|
99
+ singlelinks << SingleLink.new(link, "Dead", nil)
85
100
  end
86
- singlelinks << SingleLink.new(links[index], "#{status}")
87
101
  end
88
102
 
89
103
  links = {}
90
104
  singlelinks.each do |a|
91
105
  links[a.status] ||= []
92
- links[a.status] << a.link
106
+ links[a.status] << [a.link, a.size]
93
107
  end
94
-
95
108
  return links
96
-
97
109
  end
98
110
  end
99
111
 
100
112
  class SingleLink
101
- attr_accessor :link, :status
113
+ attr_accessor :link, :status, :size
102
114
 
103
- def initialize(link, status)
115
+ def initialize(link, status, size)
116
+ @size = size
104
117
  @link = link
105
118
  @status = status
106
119
  end
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cherrypicker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
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-20 00:00:00 +00:00
13
+ date: 2011-03-21 00:00:00 +00:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -26,7 +26,7 @@ extra_rdoc_files: []
26
26
  files:
27
27
  - .gitignore
28
28
  - Gemfile
29
- - README
29
+ - README.md
30
30
  - Rakefile
31
31
  - cherrypicker.gemspec
32
32
  - lib/cherrypicker.rb
data/README DELETED
@@ -1,38 +0,0 @@
1
- = Cherrypicker
2
-
3
- == Description
4
-
5
- Cherrypicker is a Ruby Gem that lets you download from; Rapidshare and Hotfile
6
-
7
- == Installation
8
-
9
- gem install cherrypicker
10
-
11
- == Usage
12
-
13
- require 'cherrypicker'
14
-
15
- == Examples
16
-
17
- test = Rapidshare.new("http://rapidshare.com/files/329036215/myfile.rar", "username", "password")
18
- test.download
19
-
20
- test2 = Hotfile.new("http://hotfile.com/dl/81103855/ee51a52/myfile.rar", "username", "password")
21
- test2.download
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
-
36
- == Limitations
37
-
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