cherrypicker 0.3.7 → 0.3.8

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
@@ -2,9 +2,8 @@ Cherrypicker
2
2
  =========
3
3
 
4
4
  Cherrypicker was part of my final year project for university it
5
- is a Ruby Gem that lets you download from; Rapidshare, Hotfile, Hotfile, Youtube, Vimeo & Megavideo
6
- You can also utilise the LinkChecker to see if your files are
7
- alive on Rapidshare and Hotfile
5
+ is a Ruby Gem that lets you download from; Rapidshare, Hotfile, Hotfile, Youtube, Vimeo & Megavideo
6
+ You can also utilise the LinkChecker to see if your files are alive on Rapidshare and Hotfile
8
7
 
9
8
  Enjoy!
10
9
 
@@ -58,6 +57,7 @@ fix/feature has a high chance of being included, please read the following
58
57
  guidelines:
59
58
 
60
59
  1. Post a new GitHub Issue[http://github.com/karlentwistle/Cherrypicker/issues].
60
+ 2. Write a simple unit test that includes UrlAvailable?
61
61
 
62
62
  Limitations
63
63
  -----------
data/bin/cherrypick CHANGED
@@ -28,8 +28,9 @@ parser.each{|opt, arg| options[opt.gsub('--', '').to_sym] = arg unless arg == ''
28
28
 
29
29
  if options[:directory] && !File.directory?(options[:directory]) then
30
30
  puts "Directory not found " + options[:directory]
31
+ puts
31
32
  usage
32
33
  exit
33
34
  end
34
- s
35
+
35
36
  Cherrypicker::Cherrypick.new(ARGV[0], :location => options[:directory], :username => options[:username], :password => options[:password])
@@ -1,6 +1,6 @@
1
1
  # Class that can sort Hotfile link into sections as specified by Hotfile API
2
2
  #
3
- # hotfile = Hotfile.new("http://hotfile.com/dl/110589431/6ad2666/ROT007-WEB-2011.rar.html", "username", "password")
3
+ # hotfile = Hotfile.new("http://hotfile.com/dl/110589431/6ad2666/ROT007-WEB-2011.rar.html", :username => "username", password => "password")
4
4
  # hotfile.download
5
5
 
6
6
  require 'open-uri'
@@ -1,11 +1,11 @@
1
1
  # Class that can sort Rapidshare link into sections as specified by RapidShare API
2
2
  #
3
- # rapid = Rapidshare.new("http://rapidshare.com/files/329036215/The.Matrix.bandaa25.part06.rar", "username", "password")
3
+ # rapid = Rapidshare.new("http://rapidshare.com/files/329036215/myfile.rar", "username", "password")
4
4
  # rapid.download
5
5
  require 'open-uri'
6
6
  module Cherrypicker
7
7
  class Rapidshare
8
- attr_accessor :link, :fileid, :filename, :hostname, :username, :password, :size, :location
8
+ attr_accessor :link, :fileid, :filename, :hostname, :username, :password, :size, :location, :download_url
9
9
 
10
10
  def initialize(link, opts={})
11
11
  uri = URI.parse(link)
@@ -25,6 +25,7 @@ module Cherrypicker
25
25
  @location = o[:location]
26
26
  @filename = File.basename(uri.path)
27
27
  @hostname = hostname
28
+ @download_url = @hostname + remote_url
28
29
  end
29
30
 
30
31
  def download
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -1,4 +1,14 @@
1
1
  require 'rubygems'
2
2
  require 'shoulda'
3
+ require 'net/http'
3
4
 
4
- require File.dirname(__FILE__) + '/../lib/cherrypicker'
5
+ require File.dirname(__FILE__) + '/../lib/cherrypicker'
6
+
7
+ def UrlAvailable?(url)
8
+ uri = URI.parse(url)
9
+ http = Net::HTTP.new(uri.host, uri.port)
10
+ http.use_ssl = true if uri.scheme == "https"
11
+ http.start do |http|
12
+ return http.head(uri.request_uri).code == "200"
13
+ end
14
+ end
File without changes
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ module Cherrypicker
4
+ class MegavideoTest < Test::Unit::TestCase
5
+
6
+ context "Information request" do
7
+
8
+ should "Standard video test" do
9
+ response = Megavideo.new("http://www.megavideo.com/?v=JKXPXMGA")
10
+ assert response.link =~ /[A-Z]*/
11
+ assert response.filename.length > 0
12
+ assert response.filename == "russian+president+dancing.flv"
13
+ assert response.download_url.include?("#{response.filename}")
14
+ assert UrlAvailable?(response.download_url)
15
+ end
16
+
17
+ should "Another video test" do
18
+ response = Megavideo.new("http://www.megavideo.com/?v=GYZ3NEFZ")
19
+ assert response.link =~ /[A-Z]*/
20
+ assert response.filename.length > 0
21
+ assert response.filename == "justin+bieber+-+one+time.flv"
22
+ assert response.download_url.include?("#{response.filename}")
23
+ assert UrlAvailable?(response.download_url)
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -1,17 +1,27 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
+ module Cherrypicker
2
3
 
3
- class RapidshareTest < Test::Unit::TestCase
4
+ class RapidshareTest < Test::Unit::TestCase
4
5
 
5
- context "Information request" do
6
+ context "Information request" do
6
7
 
7
- should "return response" do
8
- response = Rapidshare.new("http://rapidshare.com/files/453165880/test_file.txt", "username", "password")
9
- assert response.fileid =~ /\d*/
10
- assert response.filename.length > 0
11
- assert response.hostname.length > 0
12
- assert !response.hostname.include?("DL: ")
13
- end
8
+ should "return response https file" do
9
+ response = Rapidshare.new("https://rapidshare.com/files/453165880/test_file.txt", :username => "username", :password => "password")
10
+ assert response.fileid =~ /\d*/
11
+ assert response.filename.length > 0
12
+ assert response.hostname.length > 0
13
+ assert UrlAvailable?(response.download_url)
14
+ end
15
+
16
+ should "return response http file" do
17
+ response = Rapidshare.new("http://rapidshare.com/files/453165880/test_file.txt", :username => "username", :password => "password")
18
+ assert response.fileid =~ /\d*/
19
+ assert response.filename.length > 0
20
+ assert response.hostname.length > 0
21
+ assert UrlAvailable?(response.download_url)
22
+ end
14
23
 
15
- end
24
+ end
16
25
 
17
- end
26
+ end
27
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ module Cherrypicker
4
+ class VimeoTest < Test::Unit::TestCase
5
+
6
+ context "Information request" do
7
+
8
+ should "Standard video test" do
9
+ response = Vimeo.new("http://vimeo.com/12650554")
10
+ assert response.link =~ /\d*/
11
+ assert response.filename.length > 0
12
+ assert response.filename == "Portland_Cello_Project___Denmark.flv"
13
+ assert response.download_url.include?("token")
14
+ assert UrlAvailable?(response.download_url)
15
+ end
16
+
17
+ should "URL with a ? inside" do
18
+ response = Vimeo.new("http://vimeo.com/21712912?ab")
19
+ assert response.link =~ /\d*/
20
+ assert response.filename.length > 0
21
+ assert response.filename == "Shadows.flv"
22
+ assert response.download_url.include?("token")
23
+ assert UrlAvailable?(response.download_url)
24
+ end
25
+
26
+ should "URL with seven digits hosted on Amazon" do
27
+ response = Vimeo.new("http://vimeo.com/2171291", :location => "/Volumes/Storage/Gems/cherrypicker/movies")
28
+ assert response.link =~ /\d*/
29
+ assert response.filename.length > 0
30
+ assert response.filename == "Stephanies_Birthday__Melissa_talking_about__quot_synch_swimming_quot___and_Sheean_being_Sheean_.flv"
31
+ assert response.location == "/Volumes/Storage/Gems/cherrypicker/movies"
32
+ assert response.download_url.include?("AWSAccessKeyId")
33
+ #assert UrlAvailable?(response.download_url)
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,28 @@
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 = Youtube.new("http://www.youtube.com/watch?v=ihYq2dGa29M")
10
+ assert response.link =~ /\?v=([a-z0-9\-]+)\&*/
11
+ assert response.filename.length > 0
12
+ assert response.filename == "Why_do_people_laugh_at_creationists___part_24_.flv"
13
+ response.download_url.include?("videoplayback?sparams=id")
14
+ assert UrlAvailable?(response.download_url)
15
+ end
16
+
17
+ should "Another video test" do
18
+ response = Youtube.new("http://www.youtube.com/watch?v=nZ6-GnxKuwY")
19
+ assert response.link =~ /\?v=([a-z0-9\-]+)\&*/
20
+ assert response.filename.length > 0
21
+ assert response.filename == "The_Palace_Episode_02.mp4"
22
+ response.download_url.include?("videoplayback?sparams=id")
23
+ assert UrlAvailable?(response.download_url)
24
+ end
25
+
26
+ end
27
+ end
28
+ 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.7
5
+ version: 0.3.8
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-24 00:00:00 +01:00
13
+ date: 2011-04-25 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -52,8 +52,11 @@ files:
52
52
  - lib/cherrypicker/plugins/youtube.rb
53
53
  - lib/cherrypicker/version.rb
54
54
  - test/test_helper.rb
55
- - test/unit/hostfile_test.rb
55
+ - test/unit/hotfile_test.rb
56
+ - test/unit/megavideo_test.rb
56
57
  - test/unit/rapidshare_test.rb
58
+ - test/unit/vimeo_test.rb
59
+ - test/unit/youtube_test.rb
57
60
  has_rdoc: true
58
61
  homepage: http://karl.entwistle.info/
59
62
  licenses: []
@@ -84,5 +87,8 @@ specification_version: 3
84
87
  summary: Cherrypicker is Ruby Gem it lets you download from; Rapidshare and Hotfile
85
88
  test_files:
86
89
  - test/test_helper.rb
87
- - test/unit/hostfile_test.rb
90
+ - test/unit/hotfile_test.rb
91
+ - test/unit/megavideo_test.rb
88
92
  - test/unit/rapidshare_test.rb
93
+ - test/unit/vimeo_test.rb
94
+ - test/unit/youtube_test.rb