cherrypicker 0.3.11 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,10 +15,19 @@ module Cherrypicker
15
15
  @username = o[:username]
16
16
  @password = o[:password]
17
17
  @directory = o[:location]
18
-
18
+
19
+ plugins = ["Hotfile", "Megavideo", "Rapidshare", "Rghost", "Vimeo", "Youtube"]
19
20
  classname = URI.parse(@link.to_s).host[/[^www\.]+/].capitalize
20
- instance = Object.const_get('Cherrypicker').const_get("#{classname}")
21
- instance.new(@link, :location => @location, :username => @username, :password => @password).download
21
+
22
+ supported_host = plugins.include?(classname)
23
+
24
+ if supported_host == true
25
+ instance = Object.const_get('Cherrypicker').const_get("#{classname}")
26
+ instance.new(@link, :location => @location, :username => @username, :password => @password).download
27
+ else
28
+ Cherrypicker::download_file(@link, :location => @location)
29
+ end
30
+
22
31
  end
23
32
  end
24
33
  end
@@ -9,6 +9,7 @@ require 'net/http'
9
9
  require 'net/https'
10
10
  require 'progressbar'
11
11
  require 'open-uri'
12
+ require 'progress'
12
13
 
13
14
  module Cherrypicker
14
15
  def self.remote_query(url)
@@ -56,8 +57,11 @@ module Cherrypicker
56
57
  @size = head['content-length'] if @size.nil? && head['content-length'].to_i > 1024
57
58
  end
58
59
  end
60
+ puts "unknown file size for #{@filename}" if @size.nil?
59
61
  http.request(request) do |response|
60
62
  bar = ProgressBar.new((@filename ||= File.basename(uri.path)), @size.to_i) unless @size.nil?
63
+ bar.format_arguments=[:title, :percentage, :bar, :stat_for_file_transfer] unless @size.nil?
64
+
61
65
  File.open(@location + (@filename ||= File.basename(uri.path)), "wb") do |file|
62
66
  response.read_body do |segment|
63
67
  @progress += segment.length
@@ -67,6 +71,9 @@ module Cherrypicker
67
71
  end
68
72
  end
69
73
  @finished = true
74
+ puts
75
+ puts "download completed"
76
+ puts
70
77
  end
71
78
 
72
79
  def self.hash_to_url(hash)
@@ -0,0 +1,48 @@
1
+ # Class that can download from Vimeo
2
+ # Fileserve.new("http://www.vimeo.com/2119458", :location => "/Volumes/Storage/Desktop/cherrytest/").download
3
+
4
+ require 'rubygems'
5
+ require 'mechanize'
6
+
7
+ module Cherrypicker
8
+ class Fileserve
9
+ attr_accessor :link, :filename, :location, :download_url
10
+
11
+ def initialize(link, opts={})
12
+
13
+ o = {
14
+ :location => nil,
15
+ :username => nil,
16
+ :password => nil,
17
+ }.merge(opts)
18
+
19
+ @link = link
20
+ @filename = ""
21
+ @location = o[:location]
22
+ @download_url = ""
23
+
24
+ hostname = "http://www.fileserve.com/file/JmcsvYZ/Thor.2011.TS.READNFO.XViD-IMAGiNE.avi"
25
+
26
+ a = Mechanize.new { |agent|
27
+ agent.user_agent_alias = Cherrypicker::self.random_agent
28
+ 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
40
+
41
+ #@download_url = reply.response['location']
42
+ end
43
+
44
+ def download
45
+ # Cherrypicker::download_file(@download_url, :location => @location, :filename => @filename)
46
+ end
47
+ end
48
+ end
@@ -40,6 +40,8 @@ module Cherrypicker
40
40
  end
41
41
 
42
42
  @filename = title.delete("\"'").gsub(/[^0-9A-Za-z]/, '_') + ".mp4"
43
+ #strip out _quote_ marks
44
+ @filename.gsub!('_quot_', '')
43
45
  reply = Cherrypicker::remote_query("#{hostname}#{download_url}")
44
46
  @download_url = reply.response['location']
45
47
  end
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.3.11"
2
+ VERSION = "0.3.12"
3
3
  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.11
5
+ version: 0.3.12
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-02 00:00:00 +01:00
13
+ date: 2011-05-04 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -44,6 +44,7 @@ files:
44
44
  - lib/cherrypicker/cherrypick.rb
45
45
  - lib/cherrypicker/helpers.rb
46
46
  - lib/cherrypicker/linkchecker.rb
47
+ - lib/cherrypicker/plugins/fileserve.rb
47
48
  - lib/cherrypicker/plugins/hotfile.rb
48
49
  - lib/cherrypicker/plugins/megavideo.rb
49
50
  - lib/cherrypicker/plugins/rapidshare.rb