cherrypicker 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cherrypicker.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,25 @@
1
+ = Cherrypicker
2
+
3
+ == Description
4
+
5
+ Cherrypicker is Ruby Gem it 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
+ == Limitations
24
+
25
+ This is only useful if you're using premium accounts, this will not work without a valid username and password when downloading a file
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "cherrypicker/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "cherrypicker"
7
+ s.version = Cherrypicker::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Karl Entwistle"]
10
+ s.email = ["Karl@Entwistle.com"]
11
+ s.homepage = "http://karl.entwistle.info/"
12
+ s.summary = %q{Cherrypicker is Ruby Gem it lets you download from; Rapidshare and Hotfile}
13
+ # s.description = %q{Cherrypicker is a upload/download for sites such as Rapidshare, Hotfile, Fileserv & Filesonic}
14
+
15
+ s.rubyforge_project = "cherrypicker"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,25 @@
1
+ # Class that can download files from cyberlockers
2
+ #
3
+ # Download.new(hostname, url, username, password)
4
+ require 'net/http'
5
+
6
+ class Download
7
+ attr_accessor :hostname, :url, :filename
8
+
9
+ def initialize(hostname, url, filename)
10
+ @hostname = hostname
11
+ @url = url
12
+ @filename = filename
13
+
14
+ download
15
+ end
16
+
17
+ def download
18
+ Net::HTTP.start("#{self.hostname}") { |http|
19
+ resp = http.get("#{self.url}")
20
+ open("#{self.filename}", "wb") { |file|
21
+ file.write(resp.body)
22
+ }
23
+ }
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ # Class that can create URL from hash
2
+ #
3
+ # print Hash.new(Hash["a", "b"]).url
4
+ require 'open-uri'
5
+
6
+ class Hash
7
+ attr_accessor :hash, :url
8
+
9
+ def initialize(hash)
10
+ @hash = hash
11
+ @url = hash_to_url
12
+ end
13
+
14
+ def hash_to_url
15
+ hash = self.hash
16
+ hash.keys.inject('') do |query_string, key|
17
+ query_string << '&' unless key == hash.keys.first
18
+ query_string << "#{URI.encode(key.to_s)}=#{URI.encode(hash[key])}"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,62 @@
1
+ # Class that can sort Hotfile link into sections as specified by Hotfile API
2
+ #
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
+ require 'open-uri'
7
+
8
+ class Hotfile
9
+ attr_accessor :link, :hostname, :filename, :username, :password, :remote_url
10
+
11
+ def initialize(link, username, password)
12
+ @link = link
13
+ @username = username
14
+ @password = password
15
+ @hostname = hostname
16
+ @filename = filename
17
+ end
18
+
19
+ def download
20
+ Download.new(self.hostname, remote_url, self.filename)
21
+ end
22
+
23
+ def filename
24
+ self.link[/dl\/\d*\/[0-9a-f]*\/(.*)/, 1]
25
+ end
26
+
27
+ def create_url
28
+ Hash.new({
29
+ link: self.link,
30
+ username: self.username.to_s,
31
+ password: self.password.to_s
32
+ }).url
33
+ end
34
+
35
+ def hostname
36
+ query = "http://api.hotfile.com/?action=getdirectdownloadlink&" + create_url
37
+ begin
38
+ open(query) do |f|
39
+ f.each do |line|
40
+ return "#{line[/http:\/\/(.*).hotfile.com/, 1]}" + ".hotfile.com"
41
+ end
42
+ end
43
+ rescue SocketError
44
+ $stderr.print "IO failed: " + $!
45
+ raise
46
+ end
47
+ end
48
+
49
+ def remote_url
50
+ query = "http://api.hotfile.com/?action=getdirectdownloadlink&" + create_url
51
+ begin
52
+ open(query) do |f|
53
+ f.each do |line|
54
+ return "#{line[/http:\/\/.*.hotfile.com(.*)/, 1]}"
55
+ end
56
+ end
57
+ rescue SocketError
58
+ $stderr.print "IO failed: " + $!
59
+ raise
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,60 @@
1
+ # Class that can sort Rapidshare link into sections as specified by RapidShare API
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
+ require 'open-uri'
9
+
10
+ class Rapidshare
11
+ attr_accessor :link, :fileid, :filename, :hostname, :username, :password
12
+
13
+ def initialize(link, username, password)
14
+ @link = link
15
+ @fileid = fileid
16
+ @filename = filename
17
+ @hostname = hostname
18
+ @username = username
19
+ @password = password
20
+ end
21
+
22
+ def download
23
+ Download.new(self.hostname, remote_url, self.filename)
24
+ end
25
+
26
+ def fileid
27
+ self.link[/files\/(\d*)\//, 1]
28
+ end
29
+
30
+ def filename
31
+ self.link[/files\/\d*\/(.*)/, 1]
32
+ end
33
+
34
+ def remote_url
35
+ "/cgi-bin/rsapi.cgi?sub=download&" + create_url
36
+ end
37
+
38
+ def create_url
39
+ Hash.new({
40
+ fileid: self.fileid,
41
+ filename: self.filename,
42
+ login: self.username.to_s,
43
+ password: self.password.to_s
44
+ }).url
45
+ end
46
+
47
+ def hostname
48
+ query = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&" + create_url
49
+ begin
50
+ open(query) do |f|
51
+ f.each do |line|
52
+ return "#{line[/DL:(.*).rapidshare.com/, 1]}" + ".rapidshare.com"
53
+ end
54
+ end
55
+ rescue SocketError
56
+ $stderr.print "IO failed: " + $!
57
+ raise
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module Cherrypicker
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'cherrypicker/rapidshare'
2
+ require "cherrypicker/hotfile"
3
+ require 'cherrypicker/download'
4
+ require "cherrypicker/hash"
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cherrypicker
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Karl Entwistle
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-17 00:00:00 +00:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email:
19
+ - Karl@Entwistle.com
20
+ executables: []
21
+
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - .gitignore
28
+ - Gemfile
29
+ - README
30
+ - Rakefile
31
+ - cherrypicker.gemspec
32
+ - lib/cherrypicker.rb
33
+ - lib/cherrypicker/download.rb
34
+ - lib/cherrypicker/hash.rb
35
+ - lib/cherrypicker/hotfile.rb
36
+ - lib/cherrypicker/rapidshare.rb
37
+ - lib/cherrypicker/version.rb
38
+ has_rdoc: true
39
+ homepage: http://karl.entwistle.info/
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project: cherrypicker
62
+ rubygems_version: 1.6.1
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Cherrypicker is Ruby Gem it lets you download from; Rapidshare and Hotfile
66
+ test_files: []
67
+