Permalink
Browse files

added google video

  • Loading branch information...
1 parent 8852008 commit 9756e2cf49c609c2158dce98aee2723d08fbb1cf @karlentwistle committed May 14, 2011
View
@@ -75,6 +75,17 @@ Limitations
License
-------
- Cherypicker is free software, and may be redistributed and be used for
- anything apart from the operation of nuclear facilities, aircraft navigation
- or communication systems, air traffic control, life support or weapons systems.
+ Ruby Gem that lets you download from; Rapidshare, Hotfile, Youtube, Vimeo & Megavideo
+ Copyright (C) 2011 Karl Entwistle
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
View
@@ -44,11 +44,10 @@ end
unless directory == "" || nil?
p path = Pathname.new(directory)
-
- if not path.directory?
- puts "Directory not found " + path.to_s
- usage
- exit
+ if not path.directory?
+ puts "Directory not found " + path.to_s
+ usage
+ exit
end
end
View
@@ -7,3 +7,5 @@
require 'cherrypicker/plugins/youtube'
require 'cherrypicker/plugins/megavideo'
require "cherrypicker/plugins/rghost"
+require "cherrypicker/plugins/fileserve"
+require "cherrypicker/plugins/googlevideo"
@@ -9,6 +9,7 @@
require 'net/https'
require 'progressbar'
require 'open-uri'
+require 'cgi'
module Cherrypicker
def self.remote_query(url)
@@ -49,15 +50,13 @@ def self.download_file(link, opts={})
http.read_timeout = 3 # seconds
request = Net::HTTP::Get.new(uri.request_uri)
request.initialize_http_header({"User-Agent" => Cherrypicker::random_agent})
-
- unless (uri.host.include? 'youtube.com') && (uri.request_uri.include? 'videoplayback') #youtube throws EOFError
- head = http.request_head(URI.escape(uri.path))
karlentwistle
karlentwistle May 14, 2011 Owner

This was driving me nuts and causing the EOF error message

+
+ head = http.request_head(URI.escape(uri.request_uri))
case head
- when Net::HTTPForbidden
- @size = nil #no content-length no progress bar
- else
- @size = head['content-length'] if @size.nil? && head['content-length'].to_i > 1024
- end
+ when Net::HTTPForbidden
+ @size = nil #no content-length no progress bar
+ else
+ @size = head['content-length'] if @size.nil? && head['content-length'].to_i > 1024
end
puts "unknown file size for #{@filename} but downloading..." if @size.nil?
@@ -3,6 +3,7 @@
require 'rubygems'
require 'mechanize'
+require 'open-uri'
module Cherrypicker
class Fileserve
@@ -24,25 +25,25 @@ def initialize(link, opts={})
hostname = "http://www.fileserve.com/file/JmcsvYZ/Thor.2011.TS.READNFO.XViD-IMAGiNE.avi"
a = Mechanize.new { |agent|
- agent.user_agent_alias = Cherrypicker::self.random_agent
+ agent.user_agent_alias = 'Mac Safari'
agent.follow_meta_refresh = true
- }
-
-
- a.get(hostname) do |page|
- download_page = page.form_with(:name => 'loginForm') do |login|
- login.loginUserName = o[:username]
- login.loginUserPassword = o[:password
- end.submit
-
- puts a
- end
+ page = agent.get('http://www.fileserve.com/login.php')
+
+ form = signin_page.form_with(:name => 'login_form') do |form|
+ form.loginUserName = o[:username]
+ form.loginUserPassword = o[:password]
+ end.submit
+
+ page = agent.get('http://www.fileserve.com/login.php')
+ }
+
#@download_url = reply.response['location']
end
def download
# Cherrypicker::download_file(@download_url, :location => @location, :filename => @filename)
end
- end
-end
+ end
+end
+
@@ -0,0 +1,29 @@
+# Class that can download from Vimeo
+# Googlevideo.new("http://video.google.com/videoplay?docid=7065205277695921912", :location => "/Volumes/Storage/Desktop/cherrytest/").download
+require 'cgi'
+
+module Cherrypicker
+ class Googlevideo
+ attr_accessor :link, :filename, :location, :download_url
+
+ def initialize(link, opts={})
+
+ o = {
+ :location => nil,
+ }.merge(opts)
+
+ @link = link
+ @filename = ""
+ @location = o[:location]
+ @download_url = ""
+
+ response = Cherrypicker::remote_query(@link)
+ @filename = response.body[/<title>(.*)<\/title>/, 1]
+ @download_url = CGI.unescape(response.body[/videoUrl\\x3d(.*)\\x26thumbnailUrl/, 1])
+ end
+
+ def download
+ Cherrypicker::download_file(@download_url, :location => @location, :filename => @filename)
+ end
+ end
+end
View
No changes.
@@ -0,0 +1,25 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+module Cherrypicker
+ class YoutubeTest < Test::Unit::TestCase
+
+ context "Information request" do
+
+ should "Standard video test" do
+ response = Googlevideo.new("http://video.google.com/videoplay?docid=7065205277695921912")
+ assert response.link.length > 0
+ assert response.filename.length > 0
+ assert response.filename == "Zeitgeist: Addendum"
+ assert UrlAvailable?(response.download_url)
+ end
+
+ should "Standard video test" do
+ response = Googlevideo.new("http://video.google.com/videoplay?docid=-7060901208354599575")
+ assert response.link.length > 0
+ assert response.filename.length > 0
+ assert response.filename == "Charlie Chaplin A DogsLife"
+ assert UrlAvailable?(response.download_url)
+ end
+ end
+ end
+end

0 comments on commit 9756e2c

Please sign in to comment.