cherrypicker 0.3.14 → 0.4.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 CHANGED
@@ -75,6 +75,17 @@ Limitations
75
75
  License
76
76
  -------
77
77
 
78
- Cherypicker is free software, and may be redistributed and be used for
79
- anything apart from the operation of nuclear facilities, aircraft navigation
80
- or communication systems, air traffic control, life support or weapons systems.
78
+ Ruby Gem that lets you download from; Rapidshare, Hotfile, Youtube, Vimeo & Megavideo
79
+ Copyright (C) 2011 Karl Entwistle
80
+
81
+ This program is free software: you can redistribute it and/or modify
82
+ it under the terms of the GNU General Public License as published by
83
+ the Free Software Foundation, version 2 of the License.
84
+
85
+ This program is distributed in the hope that it will be useful,
86
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
87
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88
+ GNU General Public License for more details.
89
+
90
+ You should have received a copy of the GNU General Public License
91
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
data/bin/cherrypick CHANGED
@@ -44,11 +44,10 @@ end
44
44
 
45
45
  unless directory == "" || nil?
46
46
  p path = Pathname.new(directory)
47
-
48
- if not path.directory?
49
- puts "Directory not found " + path.to_s
50
- usage
51
- exit
47
+ if not path.directory?
48
+ puts "Directory not found " + path.to_s
49
+ usage
50
+ exit
52
51
  end
53
52
  end
54
53
 
@@ -56,7 +55,9 @@ username = nil unless username != ""
56
55
  password = nil unless password != ""
57
56
  directory = nil unless directory != ""
58
57
 
59
- if ARGV[0].include?("rapidshare.com/files/") or ARGV[0].include?("hotfile.com/dl/")
58
+ url = ARGV[0]
59
+
60
+ if url.include?("rapidshare.com/files/") or url.include?("hotfile.com/dl/")
60
61
  unless username and password != nil?
61
62
  puts "Host required username / password"
62
63
  puts
@@ -65,4 +66,13 @@ if ARGV[0].include?("rapidshare.com/files/") or ARGV[0].include?("hotfile.com/dl
65
66
  end
66
67
  end
67
68
 
68
- Cherrypicker::Cherrypick.new(ARGV[0], :location => directory, :username => username, :password => password)
69
+ #Cherrypicker::Cherrypick.new(ARGV[0], :location => directory, :username => username, :password => password)
70
+
71
+ Cherrypicker::PluginBase.registered_plugins.each do |plugin|
72
+ if plugin.matches_provider?(url)
73
+ plugin.new(url, :location => directory, :username => username, :password => password).download
74
+ exit
75
+ end
76
+ end
77
+
78
+ Cherrypicker::download_file(url, :location => directory, :username => username, :password => password)
data/lib/cherrypicker.rb CHANGED
@@ -7,3 +7,5 @@ require 'cherrypicker/plugins/hotfile'
7
7
  require 'cherrypicker/plugins/youtube'
8
8
  require 'cherrypicker/plugins/megavideo'
9
9
  require "cherrypicker/plugins/rghost"
10
+ require "cherrypicker/plugins/fileserve"
11
+ require "cherrypicker/plugins/googlevideo"
@@ -16,7 +16,11 @@ module Cherrypicker
16
16
  @password = o[:password]
17
17
  @directory = o[:location]
18
18
 
19
- plugins = ["Hotfile", "Megavideo", "Rapidshare", "Rghost", "Vimeo", "Youtube"]
19
+ Dir[File.join(File.dirname(__FILE__),"../plugins/*.rb")].each do |plugin|
20
+ load plugin
21
+ end
22
+
23
+ plugins = ["Hotfile", "Megavideo", "Rapidshare", "Rghost", "Vimeo", "Youtube", "Googlevideo"]
20
24
  classname = URI.parse(@link.to_s).host[/[^www\.]+/].capitalize
21
25
 
22
26
  supported_host = plugins.include?(classname)
@@ -9,8 +9,18 @@ require 'net/http'
9
9
  require 'net/https'
10
10
  require 'progressbar'
11
11
  require 'open-uri'
12
+ require 'cgi'
12
13
 
13
14
  module Cherrypicker
15
+ class PluginBase
16
+ class << self; attr_reader :registered_plugins end
17
+ @registered_plugins = []
18
+
19
+ def self.inherited(child)
20
+ PluginBase.registered_plugins << child
21
+ end
22
+ end
23
+
14
24
  def self.remote_query(url)
15
25
  uri = URI.parse(url)
16
26
  http = Net::HTTP.new(uri.host, uri.port)
@@ -49,15 +59,13 @@ module Cherrypicker
49
59
  http.read_timeout = 3 # seconds
50
60
  request = Net::HTTP::Get.new(uri.request_uri)
51
61
  request.initialize_http_header({"User-Agent" => Cherrypicker::random_agent})
52
-
53
- unless (uri.host.include? 'youtube.com') && (uri.request_uri.include? 'videoplayback') #youtube throws EOFError
54
- head = http.request_head(URI.escape(uri.path))
62
+
63
+ head = http.request_head(URI.escape(uri.request_uri))
55
64
  case head
56
- when Net::HTTPForbidden
57
- @size = nil #no content-length no progress bar
58
- else
59
- @size = head['content-length'] if @size.nil? && head['content-length'].to_i > 1024
60
- end
65
+ when Net::HTTPForbidden
66
+ @size = nil #no content-length no progress bar
67
+ else
68
+ @size = head['content-length'] if @size.nil? && head['content-length'].to_i > 1024
61
69
  end
62
70
 
63
71
  puts "unknown file size for #{@filename} but downloading..." if @size.nil?
@@ -3,10 +3,15 @@
3
3
 
4
4
  require 'rubygems'
5
5
  require 'mechanize'
6
+ require 'open-uri'
6
7
 
7
8
  module Cherrypicker
8
9
  class Fileserve
9
10
  attr_accessor :link, :filename, :location, :download_url
11
+
12
+ def self.matches_provider?(url)
13
+ url.include?("fileserve.com")
14
+ end
10
15
 
11
16
  def initialize(link, opts={})
12
17
 
@@ -24,19 +29,18 @@ module Cherrypicker
24
29
  hostname = "http://www.fileserve.com/file/JmcsvYZ/Thor.2011.TS.READNFO.XViD-IMAGiNE.avi"
25
30
 
26
31
  a = Mechanize.new { |agent|
27
- agent.user_agent_alias = Cherrypicker::self.random_agent
32
+ agent.user_agent_alias = 'Mac Safari'
28
33
  agent.follow_meta_refresh = true
29
- }
30
-
31
-
32
- a.get(hostname) do |page|
33
- download_page = page.form_with(:name => 'loginForm') do |login|
34
- login.loginUserName = o[:username]
35
- login.loginUserPassword = o[:password
36
- end.submit
37
-
38
- puts a
39
- end
34
+ page = agent.get('http://www.fileserve.com/login.php')
35
+
36
+ form = signin_page.form_with(:name => 'login_form') do |form|
37
+ form.loginUserName = o[:username]
38
+ form.loginUserPassword = o[:password]
39
+ end.submit
40
+
41
+ page = agent.get('http://www.fileserve.com/login.php')
42
+ }
43
+
40
44
 
41
45
  #@download_url = reply.response['location']
42
46
  end
@@ -44,5 +48,6 @@ module Cherrypicker
44
48
  def download
45
49
  # Cherrypicker::download_file(@download_url, :location => @location, :filename => @filename)
46
50
  end
47
- end
48
- end
51
+ end
52
+ end
53
+
@@ -0,0 +1,33 @@
1
+ # Class that can download from Vimeo
2
+ # Googlevideo.new("http://video.google.com/videoplay?docid=7065205277695921912", :location => "/Volumes/Storage/Desktop/cherrytest/").download
3
+ require 'cgi'
4
+
5
+ module Cherrypicker
6
+ class Googlevideo < PluginBase
7
+ attr_accessor :link, :filename, :location, :download_url
8
+
9
+ def self.matches_provider?(url)
10
+ url.include?("video.google.com")
11
+ end
12
+
13
+ def initialize(link, opts={})
14
+
15
+ o = {
16
+ :location => nil,
17
+ }.merge(opts)
18
+
19
+ @link = link
20
+ @filename = ""
21
+ @location = o[:location]
22
+ @download_url = ""
23
+
24
+ response = Cherrypicker::remote_query(@link)
25
+ @filename = response.body[/<title>(.*)<\/title>/, 1] + ".flv"
26
+ @download_url = CGI.unescape(response.body[/videoUrl\\x3d(.*)\\x26thumbnailUrl/, 1])
27
+ end
28
+
29
+ def download
30
+ Cherrypicker::download_file(@download_url, :location => @location, :filename => @filename)
31
+ end
32
+ end
33
+ end
@@ -5,9 +5,13 @@
5
5
 
6
6
  require 'open-uri'
7
7
  module Cherrypicker
8
- class Hotfile
8
+ class Hotfile < PluginBase
9
9
  attr_accessor :link, :hostname, :filename, :username, :password, :size, :location, :query
10
10
 
11
+ def self.matches_provider?(url)
12
+ url.include?("hotfile.com")
13
+ end
14
+
11
15
  def initialize(link, opts={})
12
16
  if link =~ /hotfile.com\/dl\/\d*\/[0-9a-f]*\/.*.*\.html/
13
17
  @link = link[/(.*)\.html/, 1] #remove .html from link
@@ -3,8 +3,12 @@
3
3
 
4
4
  require 'open-uri'
5
5
  module Cherrypicker
6
- class Megavideo
6
+ class Megavideo < PluginBase
7
7
  attr_accessor :link, :filename, :location, :download_url
8
+
9
+ def self.matches_provider?(url)
10
+ url.include?("megavideo.com")
11
+ end
8
12
 
9
13
  def initialize(link, opts={})
10
14
  o = {
@@ -4,9 +4,13 @@
4
4
  # rapid.download
5
5
  require 'open-uri'
6
6
  module Cherrypicker
7
- class Rapidshare
7
+ class Rapidshare < PluginBase
8
8
  attr_accessor :link, :fileid, :filename, :hostname, :username, :password, :size, :location, :download_url
9
9
 
10
+ def self.matches_provider?(url)
11
+ url.include?("rapidshare.com")
12
+ end
13
+
10
14
  def initialize(link, opts={})
11
15
  uri = URI.parse(link)
12
16
 
@@ -3,8 +3,12 @@
3
3
  require 'open-uri'
4
4
 
5
5
  module Cherrypicker
6
- class Rghost
6
+ class Rghost < PluginBase
7
7
  attr_accessor :link, :filename, :location, :download_url
8
+
9
+ def self.matches_provider?(url)
10
+ url.include?("rghost.com")
11
+ end
8
12
 
9
13
  def initialize(link, opts={})
10
14
 
@@ -9,8 +9,12 @@
9
9
  # you know, for videos
10
10
  #-->
11
11
  module Cherrypicker
12
- class Vimeo
12
+ class Vimeo < PluginBase
13
13
  attr_accessor :link, :filename, :location, :download_url
14
+
15
+ def self.matches_provider?(url)
16
+ url.include?("vimeo.com")
17
+ end
14
18
 
15
19
  def initialize(link, opts={})
16
20
 
@@ -3,8 +3,12 @@
3
3
  require 'cgi'
4
4
 
5
5
  module Cherrypicker
6
- class Youtube
6
+ class Youtube < PluginBase
7
7
  attr_accessor :link, :filename, :location, :download_url
8
+
9
+ def self.matches_provider?(url)
10
+ url.include?("youtube.com")
11
+ end
8
12
 
9
13
  def initialize(link, opts={})
10
14
 
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.3.14"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/cookies.yml ADDED
File without changes
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ module Cherrypicker
4
+ class YoutubeTest < Test::Unit::TestCase
5
+
6
+ context "Information request" do
7
+
8
+ should "Standard video test" do
9
+ response = Googlevideo.new("http://video.google.com/videoplay?docid=7065205277695921912")
10
+ assert response.link.length > 0
11
+ assert response.filename.length > 0
12
+ assert response.filename == "Zeitgeist: Addendum"
13
+ assert UrlAvailable?(response.download_url)
14
+ end
15
+
16
+ should "Standard video test" do
17
+ response = Googlevideo.new("http://video.google.com/videoplay?docid=-7060901208354599575")
18
+ assert response.link.length > 0
19
+ assert response.filename.length > 0
20
+ assert response.filename == "Charlie Chaplin A DogsLife"
21
+ assert UrlAvailable?(response.download_url)
22
+ end
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cherrypicker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.14
5
+ version: 0.4.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-05-04 00:00:00 +01:00
13
+ date: 2011-05-14 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -45,6 +45,7 @@ files:
45
45
  - lib/cherrypicker/helpers.rb
46
46
  - lib/cherrypicker/linkchecker.rb
47
47
  - lib/cherrypicker/plugins/fileserve.rb
48
+ - lib/cherrypicker/plugins/googlevideo.rb
48
49
  - lib/cherrypicker/plugins/hotfile.rb
49
50
  - lib/cherrypicker/plugins/megavideo.rb
50
51
  - lib/cherrypicker/plugins/rapidshare.rb
@@ -52,7 +53,9 @@ files:
52
53
  - lib/cherrypicker/plugins/vimeo.rb
53
54
  - lib/cherrypicker/plugins/youtube.rb
54
55
  - lib/cherrypicker/version.rb
56
+ - lib/cookies.yml
55
57
  - test/test_helper.rb
58
+ - test/unit/googlevideo_test.rb
56
59
  - test/unit/hotfile_test.rb
57
60
  - test/unit/megavideo_test.rb
58
61
  - test/unit/rapidshare_test.rb
@@ -90,6 +93,7 @@ specification_version: 3
90
93
  summary: Cherrypicker is Ruby Gem it lets you download from; Rapidshare and Hotfile
91
94
  test_files:
92
95
  - test/test_helper.rb
96
+ - test/unit/googlevideo_test.rb
93
97
  - test/unit/hotfile_test.rb
94
98
  - test/unit/megavideo_test.rb
95
99
  - test/unit/rapidshare_test.rb