cherrypicker 0.2.7 → 0.3.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.md +7 -7
- data/lib/cherrypicker/download.rb +33 -31
- data/lib/cherrypicker/{functions.rb → helpers.rb} +1 -1
- data/lib/cherrypicker/plugins/hotfile.rb +19 -27
- data/lib/cherrypicker/plugins/rapidshare.rb +15 -13
- data/lib/cherrypicker/plugins/vimeo.rb +9 -4
- data/lib/cherrypicker/version.rb +1 -1
- data/lib/cherrypicker.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -31,13 +31,13 @@ Examples
|
|
31
31
|
"http://rapidshare.com/files/329036215/myfile.rar",
|
32
32
|
"http://rapidshare.com/files/329036764/deadfile.rar"]).status
|
33
33
|
|
34
|
-
test3 = Rapidshare.new("http://rapidshare.com/files/329036215/myfile.rar", "username", "password",
|
34
|
+
test3 = Rapidshare.new("http://rapidshare.com/files/329036215/myfile.rar", "username", "password", :size => 10000, :location => "/location/tosave/file/")
|
35
35
|
test3.download
|
36
36
|
|
37
|
-
Vimeo.new("http://www.vimeo.com/2119458", "/Volumes/Storage/Desktop/cherrytest/").download
|
37
|
+
Vimeo.new("http://www.vimeo.com/2119458", :location => "/Volumes/Storage/Desktop/cherrytest/").download
|
38
38
|
|
39
|
-
Download.new("http://download.thinkbroadband.com/10MB.zip", "/location/tosave/file/")
|
40
|
-
Download.new("http://download.thinkbroadband.com/10MB.zip", "/location/tosave/file/",
|
39
|
+
Download.new("http://download.thinkbroadband.com/10MB.zip", :location => "/location/tosave/file/")
|
40
|
+
Download.new("http://download.thinkbroadband.com/10MB.zip", :location => "/location/tosave/file/", :size => 10485760)
|
41
41
|
|
42
42
|
Contributing
|
43
43
|
------------
|
@@ -51,15 +51,15 @@ guidelines:
|
|
51
51
|
Limitations
|
52
52
|
-----------
|
53
53
|
|
54
|
-
1. The download function is only useful if you're using premium accounts,
|
54
|
+
1. The download function for cyberlockers is only useful if you're using premium accounts,
|
55
55
|
this will not work without a valid username and password when downloading a file
|
56
56
|
|
57
57
|
2. The linkchecker is subject to throttling from both Hotfile and Rapidshare
|
58
|
-
so don't abuse it
|
58
|
+
so don't abuse it or your IP address could get banned
|
59
59
|
|
60
60
|
3. I frequently have problems accessing file hosting sites because one of their
|
61
61
|
files has been included on the IWF list and the ISP IWF filtering screws things up.
|
62
|
-
(Im on Virgin Media)
|
62
|
+
(Im on Virgin Media UK)
|
63
63
|
|
64
64
|
License
|
65
65
|
-------
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# Class that can download files from cyberlockers or generic URLs
|
2
|
-
#
|
3
|
-
# Download.new("http://download.thinkbroadband.com/10MB.zip",
|
4
|
-
# Download.new("http://download.thinkbroadband.com/10MB.zip",
|
1
|
+
# Class that can download files from cyberlockers or generic URLs
|
2
|
+
# it will try and auto detect the size and filename if not supplied
|
3
|
+
# Download.new("http://download.thinkbroadband.com/10MB.zip", :location => '/location/tosave/file/')
|
4
|
+
# Download.new("http://download.thinkbroadband.com/10MB.zip", :location => '/location/tosave/file/', :size => 10485760)
|
5
5
|
|
6
6
|
require 'net/http'
|
7
7
|
require 'net/https'
|
@@ -9,46 +9,48 @@ require 'progressbar'
|
|
9
9
|
require 'open-uri'
|
10
10
|
|
11
11
|
class Download
|
12
|
-
attr_accessor :link, :size, :location, :progress, :filename
|
12
|
+
attr_accessor :link, :size, :location, :progress, :filename, :finished
|
13
13
|
|
14
|
-
def initialize(link,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def initialize(link, opts={})
|
15
|
+
o = {
|
16
|
+
:location => nil,
|
17
|
+
:size => nil,
|
18
|
+
:filename => nil
|
19
|
+
}.merge(opts)
|
20
|
+
|
21
|
+
@link = link
|
22
|
+
@size = o[:size]
|
23
|
+
@location = o[:location]
|
24
|
+
@filename = o[:filename]
|
19
25
|
@progress = 0
|
20
|
-
|
26
|
+
@finished = false
|
27
|
+
|
21
28
|
download_file
|
22
29
|
end
|
23
30
|
|
24
31
|
def download_file
|
25
|
-
|
32
|
+
p uri = URI.parse(@link.to_s)
|
26
33
|
http = Net::HTTP.new(uri.host, uri.port)
|
27
34
|
http.use_ssl = true if uri.scheme == "https"
|
28
35
|
request = Net::HTTP::Get.new(uri.request_uri)
|
29
36
|
request.initialize_http_header({"User-Agent" => random_agent})
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
File.open(@location + (@filename ||= File.basename(uri.path)), "wb") do |file|
|
35
|
-
response.read_body do |segment|
|
36
|
-
@progress += segment.length
|
37
|
-
file.write(segment)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
37
|
+
head = http.request_head(URI.escape(uri.path))
|
38
|
+
case head
|
39
|
+
when Net::HTTPForbidden
|
40
|
+
@size = nil #no content-length no progress bar
|
41
41
|
else
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
@size = head['content-length'] if @size.nil? && head['content-length'].to_i > 1024
|
43
|
+
end
|
44
|
+
http.request(request) do |response|
|
45
|
+
bar = ProgressBar.new((@filename ||= File.basename(uri.path)), @size.to_i) unless @size.nil?
|
46
|
+
File.open(@location + (@filename ||= File.basename(uri.path)), "wb") do |file|
|
47
|
+
response.read_body do |segment|
|
48
|
+
@progress += segment.length
|
49
|
+
bar.set(@progress) unless @size.nil?
|
50
|
+
file.write(segment)
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
54
|
+
@finished = true
|
53
55
|
end
|
54
56
|
end
|
@@ -34,6 +34,6 @@ def hash_to_url(hash)
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def random_agent
|
37
|
-
@useragent = ["Mozilla/5.0 (
|
37
|
+
@useragent = ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"]
|
38
38
|
return @useragent[0]
|
39
39
|
end
|
@@ -1,55 +1,47 @@
|
|
1
1
|
# Class that can sort Hotfile link into sections as specified by Hotfile API
|
2
2
|
#
|
3
3
|
# hotfile = Hotfile.new("http://hotfile.com/dl/110589431/6ad2666/ROT007-WEB-2011.rar.html", "username", "password")
|
4
|
-
# puts hotfile.link
|
5
|
-
# puts hotfile.hostname
|
6
4
|
# hotfile.download
|
5
|
+
|
7
6
|
require 'open-uri'
|
8
7
|
|
9
8
|
class Hotfile
|
10
|
-
attr_accessor :link, :hostname, :filename, :username, :password, :size, :location
|
11
|
-
|
12
|
-
def initialize(link, username, password,
|
13
|
-
uri = URI.parse(link)
|
9
|
+
attr_accessor :link, :hostname, :filename, :username, :password, :size, :location, :query
|
10
|
+
|
11
|
+
def initialize(link, username, password, opts={})
|
14
12
|
if link =~ /hotfile.com\/dl\/\d*\/[0-9a-f]*\/.*.*\.html/
|
15
|
-
@link = link[/(.*)\.html/, 1]
|
13
|
+
@link = link[/(.*)\.html/, 1] #remove .html from link
|
16
14
|
else
|
17
15
|
@link = link
|
18
16
|
end
|
17
|
+
|
18
|
+
uri = URI.parse(@link)
|
19
|
+
|
20
|
+
o = {
|
21
|
+
:location => nil,
|
22
|
+
:size => nil,
|
23
|
+
}.merge(opts)
|
24
|
+
|
19
25
|
@username = username
|
20
26
|
@password = password
|
21
|
-
@
|
27
|
+
@size = o[:size]
|
28
|
+
@location = o[:location]
|
22
29
|
@filename = File.basename(uri.path)
|
23
|
-
@size = size
|
24
|
-
@location = location
|
25
30
|
end
|
26
31
|
|
27
32
|
def download
|
28
|
-
Download.new(
|
29
|
-
end
|
30
|
-
|
31
|
-
def filename
|
32
|
-
@link[/dl\/\d*\/[0-9a-f]*\/(.*)/, 1]
|
33
|
+
Download.new(download_url, :location => @location, :size => @size, :filename => @filename)
|
33
34
|
end
|
34
35
|
|
35
36
|
def create_url
|
36
37
|
hash_to_url({
|
37
38
|
:link => @link,
|
38
39
|
:username => @username.to_s,
|
39
|
-
:password => @password.to_s
|
40
|
+
:password => @password.to_s,
|
40
41
|
})
|
41
42
|
end
|
42
43
|
|
43
|
-
def
|
44
|
-
|
45
|
-
query.response.body
|
46
|
-
end
|
47
|
-
|
48
|
-
def hostname
|
49
|
-
"#{request[/http:\/\/(.*).hotfile.com/, 1]}" + ".hotfile.com"
|
50
|
-
end
|
51
|
-
|
52
|
-
def remote_url
|
53
|
-
"#{request[/http:\/\/.*.hotfile.com(.*)/, 1]}"
|
44
|
+
def download_url
|
45
|
+
remote_query("http://api.hotfile.com/?action=getdirectdownloadlink&" + create_url).response.body.gsub(/\n/,'')
|
54
46
|
end
|
55
47
|
end
|
@@ -1,30 +1,32 @@
|
|
1
1
|
# Class that can sort Rapidshare link into sections as specified by RapidShare API
|
2
2
|
#
|
3
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
4
|
# rapid.download
|
9
5
|
require 'open-uri'
|
10
6
|
|
11
7
|
class Rapidshare
|
12
8
|
attr_accessor :link, :fileid, :filename, :hostname, :username, :password, :size, :location
|
13
|
-
|
14
|
-
def initialize(link, username, password,
|
15
|
-
uri = URI.parse(link)
|
9
|
+
|
10
|
+
def initialize(link, username, password, opts={})
|
11
|
+
uri = URI.parse(link)
|
12
|
+
|
13
|
+
o = {
|
14
|
+
:location => nil,
|
15
|
+
:size => nil,
|
16
|
+
}.merge(opts)
|
17
|
+
|
16
18
|
@link = link
|
19
|
+
@username = username
|
20
|
+
@password = password
|
17
21
|
@fileid = fileid
|
22
|
+
@size = o[:size]
|
23
|
+
@location = o[:location]
|
18
24
|
@filename = File.basename(uri.path)
|
19
25
|
@hostname = hostname
|
20
|
-
@username = username
|
21
|
-
@password = password
|
22
|
-
@size = size
|
23
|
-
@location = location
|
24
26
|
end
|
25
27
|
|
26
28
|
def download
|
27
|
-
Download.new(@hostname + remote_url, @location, @size, @filename)
|
29
|
+
Download.new(@hostname + remote_url, :location => @location, :size => @size, :filename => @filename)
|
28
30
|
end
|
29
31
|
|
30
32
|
def fileid
|
@@ -40,7 +42,7 @@ class Rapidshare
|
|
40
42
|
:fileid => @fileid,
|
41
43
|
:filename => @filename,
|
42
44
|
:login => @username.to_s,
|
43
|
-
:password => @password.to_s
|
45
|
+
:password => @password.to_s,
|
44
46
|
})
|
45
47
|
end
|
46
48
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Class that can download from Vimeo
|
2
|
-
# Vimeo.new("http://www.vimeo.com/2119458", "/Volumes/Storage/Desktop/cherrytest/").download
|
2
|
+
# Vimeo.new("http://www.vimeo.com/2119458", :location => "/Volumes/Storage/Desktop/cherrytest/").download
|
3
3
|
|
4
4
|
#<!-- _
|
5
5
|
# __ _|_|_ __ ___ ___ ___
|
@@ -12,10 +12,15 @@
|
|
12
12
|
class Vimeo
|
13
13
|
attr_accessor :link, :filename, :location, :download_url
|
14
14
|
|
15
|
-
def initialize(link,
|
15
|
+
def initialize(link, opts={})
|
16
|
+
|
17
|
+
o = {
|
18
|
+
:location => nil,
|
19
|
+
}.merge(opts)
|
20
|
+
|
16
21
|
@link = link
|
17
22
|
@filename = ""
|
18
|
-
@location = location
|
23
|
+
@location = o[:location]
|
19
24
|
@download_url = ""
|
20
25
|
|
21
26
|
hostname = "http://www.vimeo.com/moogaloop/play/clip"
|
@@ -40,6 +45,6 @@ class Vimeo
|
|
40
45
|
end
|
41
46
|
|
42
47
|
def download
|
43
|
-
Download.new(@download_url, @location)
|
48
|
+
Download.new(@download_url, :location => @location)
|
44
49
|
end
|
45
50
|
end
|
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.
|
5
|
+
version: 0.3.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-04-
|
13
|
+
date: 2011-04-21 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -41,7 +41,7 @@ files:
|
|
41
41
|
- cherrypicker.gemspec
|
42
42
|
- lib/cherrypicker.rb
|
43
43
|
- lib/cherrypicker/download.rb
|
44
|
-
- lib/cherrypicker/
|
44
|
+
- lib/cherrypicker/helpers.rb
|
45
45
|
- lib/cherrypicker/linkchecker.rb
|
46
46
|
- lib/cherrypicker/plugins/hotfile.rb
|
47
47
|
- lib/cherrypicker/plugins/rapidshare.rb
|