cherrypicker 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,7 @@ 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
5
+ is a Ruby Gem that lets you download from; Rapidshare, Hotfile, rghost, Youtube, Vimeo & Megavideo
6
6
  You can also utilise the LinkChecker to see if your files are alive on Rapidshare and Hotfile
7
7
 
8
8
  Enjoy!
data/bin/cherrypick CHANGED
@@ -5,7 +5,7 @@ require 'getoptlong'
5
5
  require 'pathname'
6
6
 
7
7
  def usage()
8
- puts "Cherrypicker lets you download from; Rapidshare, Hotfile, Youtube, Vimeo & Megavideo"
8
+ puts "Cherrypicker lets you download from; Rapidshare, Hotfile, rhost, Youtube, Vimeo & Megavideo"
9
9
  puts "Usage: cherrypick link [--directory|-d] [--username|-u] [--password|-p]"
10
10
  puts
11
11
  puts "example: cherrypick http://www.youtube.com/watch?v=I5DCwN28y8o -d \"~/Movies\""
@@ -17,24 +17,47 @@ if not ARGV[0]
17
17
  exit
18
18
  end
19
19
 
20
- #refactored by Hamac credit http://is.gd/sbxAwG
21
- options = {username: nil, password: nil, directory: nil}
22
-
23
20
  parser = GetoptLong.new
24
- parser.set_options(*options.keys.map{|opt| ["--#{opt.to_s}", "-#{opt.to_s[0]}", GetoptLong::REQUIRED_ARGUMENT]}
21
+ parser.set_options(
22
+ ["-d", "--directory", GetoptLong::REQUIRED_ARGUMENT],
23
+ ["-u", "--username", GetoptLong::REQUIRED_ARGUMENT],
24
+ ["-p", "--password", GetoptLong::REQUIRED_ARGUMENT]
25
25
  )
26
26
 
27
- parser.each{|opt, arg| options[opt.gsub('--', '').to_sym] = arg unless arg == ''}
27
+ username = ""
28
+ password = ""
29
+ directory = ""
30
+
31
+ loop do
32
+ opt, arg = parser.get
33
+ break if not opt
34
+
35
+ case opt
36
+ when "-u"
37
+ username = arg
38
+ when "-p"
39
+ password = arg
40
+ when "-d"
41
+ directory = arg
42
+ end
43
+ end
44
+
45
+ unless directory == "" || nil?
46
+ p path = Pathname.new(directory)
28
47
 
29
- if options[:directory] && !File.directory?(options[:directory]) then
30
- puts "Directory not found " + options[:directory]
31
- puts
32
- usage
33
- exit
48
+ if not path.directory?
49
+ puts "Directory not found " + path.to_s
50
+ usage
51
+ exit
52
+ end
34
53
  end
35
54
 
55
+ username = nil unless username != ""
56
+ password = nil unless password != ""
57
+ directory = nil unless directory != ""
58
+
36
59
  if ARGV[0].include?("rapidshare.com/files/") or ARGV[0].include?("hotfile.com/dl/")
37
- unless options[:username] and options[:password] != nil?
60
+ unless username and password != nil?
38
61
  puts "Host required username / password"
39
62
  puts
40
63
  usage
@@ -42,4 +65,4 @@ if ARGV[0].include?("rapidshare.com/files/") or ARGV[0].include?("hotfile.com/dl
42
65
  end
43
66
  end
44
67
 
45
- Cherrypicker::Cherrypick.new(ARGV[0], :location => options[:directory], :username => options[:username], :password => options[:password])
68
+ Cherrypicker::Cherrypick.new(ARGV[0], :location => directory, :username => username, :password => password)
data/lib/cherrypicker.rb CHANGED
@@ -7,3 +7,4 @@ require 'cherrypicker/plugins/rapidshare'
7
7
  require 'cherrypicker/plugins/hotfile'
8
8
  require 'cherrypicker/plugins/youtube'
9
9
  require 'cherrypicker/plugins/megavideo'
10
+ require "cherrypicker/plugins/rghost"
@@ -29,7 +29,7 @@ module Cherrypicker
29
29
 
30
30
  download_file
31
31
  end
32
-
32
+
33
33
  def download_file
34
34
  uri = URI.parse(@link.to_s)
35
35
  http = Net::HTTP.new(uri.host, uri.port)
@@ -0,0 +1,39 @@
1
+ # Class that can download from rghost
2
+ # Rghost.new("http://rghost.net/5420316", :location => "/Volumes/Storage/Desktop/cherrytest/").download
3
+ require 'open-uri'
4
+
5
+ module Cherrypicker
6
+ class Rghost
7
+ attr_accessor :link, :filename, :location, :download_url
8
+
9
+ def initialize(link, opts={})
10
+
11
+ o = {
12
+ :location => nil,
13
+ }.merge(opts)
14
+
15
+ @link = link
16
+ @filename = ""
17
+ @location = o[:location]
18
+ @download_url = ""
19
+
20
+ #the rghost ID consists of decimal numbers in the URL
21
+ rghost_id = @link[/\d+/]
22
+ response = Cherrypicker::remote_query("http://rghost.net/#{rghost_id}")
23
+
24
+ @filename = response.body[/<title>(.*\.[a-zA-Z]*).*RGhost/, 1]
25
+ download_url = URI.encode(response.body[/<a href="(.*)" class=\"(file_link|download_link)\"/, 1])
26
+
27
+ reply = Cherrypicker::remote_query("#{download_url}")
28
+ if reply.response['location']
29
+ @download_url = reply.response['location']
30
+ else
31
+ @download_url = download_url
32
+ end
33
+ end
34
+
35
+ def download
36
+ Download.new(@download_url, :location => @location)
37
+ end
38
+ end
39
+ end
@@ -57,8 +57,15 @@ module Cherrypicker
57
57
  format_ext["17"] = ["3gp", "3gp"]
58
58
  format_ext["5"] = ["flv", "old default?"]
59
59
 
60
- @download_url = video_info_hash["fmt_url_map"][formats.first]
61
- @filename = video_info_hash["title"].delete("\"'").gsub(/[^0-9A-Za-z]/, '_') + "." + format_ext[formats.first].first
60
+ download_url = video_info_hash["fmt_url_map"][formats.first]
61
+ @filename = video_info_hash["title"].delete("\"'").gsub(/[^0-9A-Za-z]/, '_') + "." + format_ext[formats.first].first
62
+
63
+ reply = Cherrypicker::remote_query("#{download_url}")
64
+ if reply.response['location']
65
+ @download_url = reply.response['location']
66
+ else
67
+ @download_url = download_url
68
+ end
62
69
  end
63
70
 
64
71
  def download
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.10"
3
3
  end
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ module Cherrypicker
4
+ class RghostTest < Test::Unit::TestCase
5
+
6
+ context "Information request" do
7
+
8
+ should "Standard download test" do
9
+ response = Rghost.new("http://rghost.net/5420316")
10
+ assert response.link =~ /\d*/
11
+ assert response.filename.length > 0
12
+ assert response.filename == "cherrypicker2.png"
13
+ assert UrlAvailable?(response.download_url)
14
+ end
15
+
16
+ should "Standard download test" do
17
+ response = Rghost.new("http://rghost.net/5420928")
18
+ assert response.link =~ /\d*/
19
+ assert response.filename.length > 0
20
+ assert response.filename == "aimqpad.rar"
21
+ assert UrlAvailable?(response.download_url)
22
+ end
23
+
24
+ should "Standard download test" do
25
+ response = Rghost.new("http://rghost.net/5421019")
26
+ assert response.link =~ /\d*/
27
+ assert response.filename.length > 0
28
+ assert response.filename == "saw.ogg"
29
+ assert UrlAvailable?(response.download_url)
30
+ end
31
+ end
32
+ end
33
+ end
data/uml.png ADDED
Binary file
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cherrypicker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.9
5
+ version: 0.3.10
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-25 00:00:00 +01:00
13
+ date: 2011-05-01 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -48,6 +48,7 @@ files:
48
48
  - lib/cherrypicker/plugins/hotfile.rb
49
49
  - lib/cherrypicker/plugins/megavideo.rb
50
50
  - lib/cherrypicker/plugins/rapidshare.rb
51
+ - lib/cherrypicker/plugins/rghost.rb
51
52
  - lib/cherrypicker/plugins/vimeo.rb
52
53
  - lib/cherrypicker/plugins/youtube.rb
53
54
  - lib/cherrypicker/version.rb
@@ -55,8 +56,10 @@ files:
55
56
  - test/unit/hotfile_test.rb
56
57
  - test/unit/megavideo_test.rb
57
58
  - test/unit/rapidshare_test.rb
59
+ - test/unit/rghost_test.rb
58
60
  - test/unit/vimeo_test.rb
59
61
  - test/unit/youtube_test.rb
62
+ - uml.png
60
63
  has_rdoc: true
61
64
  homepage: http://karl.entwistle.info/
62
65
  licenses: []
@@ -90,5 +93,6 @@ test_files:
90
93
  - test/unit/hotfile_test.rb
91
94
  - test/unit/megavideo_test.rb
92
95
  - test/unit/rapidshare_test.rb
96
+ - test/unit/rghost_test.rb
93
97
  - test/unit/vimeo_test.rb
94
98
  - test/unit/youtube_test.rb