sexy_download 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/LICENSE +20 -0
- data/README.rdoc +33 -0
- data/Rakefile +19 -0
- data/VERSION +1 -0
- data/bin/sexy_download +5 -0
- data/lib/sexy_download.rb +128 -0
- data/sexy_download.gemspec +52 -0
- metadata +106 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Túlio Ornelas
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
= Sexy_download
|
2
|
+
|
3
|
+
A Script that retrieves google chrome cookies and calls aria2c for multithreading download
|
4
|
+
|
5
|
+
== Install
|
6
|
+
|
7
|
+
gem install sexy_download
|
8
|
+
|
9
|
+
You still need to install aria2 in your machine, I did not include this process on this gem. In Mac OSX try:
|
10
|
+
|
11
|
+
sudo port install aria2
|
12
|
+
|
13
|
+
or
|
14
|
+
|
15
|
+
sudo brew install aria2
|
16
|
+
|
17
|
+
== Usage
|
18
|
+
|
19
|
+
sexy_download http://someStorageService.com?q=MVGHT ~/My/Download/Path
|
20
|
+
|
21
|
+
or
|
22
|
+
|
23
|
+
sexy_download http://someStorageService.com?q=MVGHT
|
24
|
+
|
25
|
+
Without the target path +sexy_download+ will save the file in the folder that you call it
|
26
|
+
|
27
|
+
== Considerations
|
28
|
+
|
29
|
+
- I just tested this script with MAC OSX
|
30
|
+
- I just use Google Chrome
|
31
|
+
- I download most of my files with megaUpload using a paid account (It works with other services too)
|
32
|
+
- My better result was 3.5 mb/s
|
33
|
+
- I just solved my problem and maybe one day I will improve this script ;)
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "sexy_download"
|
5
|
+
gemspec.summary = "A Script that retrieves google chrome cookies and calls aria2c for multithreading download"
|
6
|
+
gemspec.description = "A Script that retrieves google chrome cookies and calls aria2c for multithreading download"
|
7
|
+
gemspec.email = "ornelas.tulio@gmail.com"
|
8
|
+
gemspec.homepage = "http://github.com/tulios/sexy_download"
|
9
|
+
gemspec.authors = ["Túlio Ornelas"]
|
10
|
+
|
11
|
+
gemspec.add_runtime_dependency("sqlite3", "~> 1.3.3")
|
12
|
+
gemspec.add_runtime_dependency("activerecord", "~> 3.0.9")
|
13
|
+
|
14
|
+
gemspec.executables = ["sexy_download"]
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
19
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/sexy_download
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'etc'
|
6
|
+
|
7
|
+
require 'sqlite3'
|
8
|
+
require 'active_record'
|
9
|
+
|
10
|
+
class CookieExtractor
|
11
|
+
|
12
|
+
CHROME_COOKIES_FILE_MAC_OSX = "Library/Application Support/Google/Chrome/Default/Cookies"
|
13
|
+
|
14
|
+
def initialize domain, dir
|
15
|
+
@domain, @dir, @cookies_txt = domain, dir, []
|
16
|
+
end
|
17
|
+
|
18
|
+
def extract!
|
19
|
+
find_host_key!
|
20
|
+
generate_cookie!(read_cookie!)
|
21
|
+
@file_path
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def find_host_key!
|
26
|
+
server = @domain.scan(/:\/\/([^:#\/\?]+)/).flatten.first
|
27
|
+
raise "Malformed domain!" unless server
|
28
|
+
|
29
|
+
parts = server.split(".")
|
30
|
+
@host_key = ".#{parts[-2]}.#{parts[-1]}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def host_only? host
|
34
|
+
(host =~ /#{@host_key}/) == 0
|
35
|
+
end
|
36
|
+
|
37
|
+
def host_only_str cookie
|
38
|
+
host_only?(cookie["host_key"]).to_s.upcase
|
39
|
+
end
|
40
|
+
|
41
|
+
def secure? secure
|
42
|
+
secure.to_i == 1
|
43
|
+
end
|
44
|
+
|
45
|
+
def secure_str cookie
|
46
|
+
secure?(cookie["secure"]).to_s.upcase
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_connection
|
50
|
+
puts "\n== Reading cookies from #{@host_key} ..."
|
51
|
+
@cookie_db = "#{File.expand_path(Etc.getpwuid.dir)}/#{CHROME_COOKIES_FILE_MAC_OSX}"
|
52
|
+
@db = ActiveRecord::Base.establish_connection(
|
53
|
+
:adapter => "sqlite3",
|
54
|
+
:database => @cookie_db
|
55
|
+
)
|
56
|
+
@db.connection
|
57
|
+
end
|
58
|
+
|
59
|
+
def read_cookie!
|
60
|
+
connection = get_connection
|
61
|
+
cookies = connection.execute("SELECT host_key, path, secure, expires_utc, name, value FROM cookies where host_key like '%#{@host_key}%'")
|
62
|
+
|
63
|
+
@cookies_txt << "# Cookies for domains related to <b>" + @domain + "</b>."
|
64
|
+
@cookies_txt << "# This content may be pasted into a cookies.txt file and used by wget"
|
65
|
+
@cookies_txt << "# Example: wget -x --load-cookies cookies.txt #{@domain}"
|
66
|
+
@cookies_txt << "#"
|
67
|
+
|
68
|
+
cookies.each do |cookie|
|
69
|
+
if cookie["host_key"] =~ /#{@host_key}/
|
70
|
+
line = []
|
71
|
+
line << cookie["host_key"]
|
72
|
+
line << host_only_str(cookie)
|
73
|
+
line << cookie["path"]
|
74
|
+
line << secure_str(cookie)
|
75
|
+
line << cookie["expires_utc"] ? cookie["expires_utc"] : "0"
|
76
|
+
line << cookie["name"]
|
77
|
+
line << cookie["value"]
|
78
|
+
|
79
|
+
@cookies_txt << line.join("\t")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
@cookies_txt.join("\n")
|
84
|
+
end
|
85
|
+
|
86
|
+
def generate_cookie! cookies_txt
|
87
|
+
puts "\n== Exporting cookies..."
|
88
|
+
file_name = "cookies_#{Time.now.to_i.to_s}.txt"
|
89
|
+
|
90
|
+
file = File.new(@dir.nil? ? file_name : File.join(@dir, file_name), "w")
|
91
|
+
file.write(cookies_txt)
|
92
|
+
@file_path = file.path
|
93
|
+
file.close
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
raise %{
|
98
|
+
\nThis script is totally based on aria2 (http://aria2.sourceforge.net/)
|
99
|
+
I did not find on your machine using 'which aria2c'
|
100
|
+
In Mac OSX try:
|
101
|
+
- sudo port install aria2
|
102
|
+
or
|
103
|
+
- brew install aria2
|
104
|
+
or
|
105
|
+
Download and compile it yourself
|
106
|
+
;)\n
|
107
|
+
} if `which aria2c`.empty?
|
108
|
+
|
109
|
+
raise %{
|
110
|
+
\nYou forgot to inform the download url, like:
|
111
|
+
$ sexy_download http://myDownloadUrl.com?q=ZHGT ~/My/Target/Dir
|
112
|
+
or
|
113
|
+
$ sexy_download http://myDownloadUrl.com?q=ZHGT\n
|
114
|
+
} if ARGV[0].nil?
|
115
|
+
|
116
|
+
@domain = ARGV[0]
|
117
|
+
@dir = File.expand_path(ARGV[1] || ".")
|
118
|
+
@file_path = CookieExtractor.new(@domain, @dir).extract!
|
119
|
+
|
120
|
+
command = %{aria2c -c -x16 #{@domain} --load-cookies="#{@file_path}"}
|
121
|
+
command << %{ --dir="#{@dir}"} if @dir
|
122
|
+
puts "\n== Downloading with:"
|
123
|
+
puts "\t#{command}\n"
|
124
|
+
|
125
|
+
system(command)
|
126
|
+
|
127
|
+
puts "\n== Deleting #{@file_path}"
|
128
|
+
File.delete @file_path
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sexy_download}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["T\303\272lio Ornelas"]
|
12
|
+
s.date = %q{2011-08-05}
|
13
|
+
s.default_executable = %q{sexy_download}
|
14
|
+
s.description = %q{A Script that retrieves google chrome cookies and calls aria2c for multithreading download}
|
15
|
+
s.email = %q{ornelas.tulio@gmail.com}
|
16
|
+
s.executables = ["sexy_download"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".gitignore",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/sexy_download",
|
28
|
+
"lib/sexy_download.rb",
|
29
|
+
"sexy_download.gemspec"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/tulios/sexy_download}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.6.2}
|
35
|
+
s.summary = %q{A Script that retrieves google chrome cookies and calls aria2c for multithreading download}
|
36
|
+
|
37
|
+
if s.respond_to? :specification_version then
|
38
|
+
s.specification_version = 3
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
|
+
s.add_runtime_dependency(%q<sqlite3>, ["~> 1.3.3"])
|
42
|
+
s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.9"])
|
43
|
+
else
|
44
|
+
s.add_dependency(%q<sqlite3>, ["~> 1.3.3"])
|
45
|
+
s.add_dependency(%q<activerecord>, ["~> 3.0.9"])
|
46
|
+
end
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<sqlite3>, ["~> 1.3.3"])
|
49
|
+
s.add_dependency(%q<activerecord>, ["~> 3.0.9"])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sexy_download
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "T\xC3\xBAlio Ornelas"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-08-05 00:00:00 -03:00
|
19
|
+
default_executable: sexy_download
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: sqlite3
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 29
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 3
|
33
|
+
- 3
|
34
|
+
version: 1.3.3
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: activerecord
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 21
|
46
|
+
segments:
|
47
|
+
- 3
|
48
|
+
- 0
|
49
|
+
- 9
|
50
|
+
version: 3.0.9
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
description: A Script that retrieves google chrome cookies and calls aria2c for multithreading download
|
54
|
+
email: ornelas.tulio@gmail.com
|
55
|
+
executables:
|
56
|
+
- sexy_download
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files:
|
60
|
+
- LICENSE
|
61
|
+
- README.rdoc
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- LICENSE
|
65
|
+
- README.rdoc
|
66
|
+
- Rakefile
|
67
|
+
- VERSION
|
68
|
+
- bin/sexy_download
|
69
|
+
- lib/sexy_download.rb
|
70
|
+
- sexy_download.gemspec
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: http://github.com/tulios/sexy_download
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options:
|
77
|
+
- --charset=UTF-8
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.6.2
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: A Script that retrieves google chrome cookies and calls aria2c for multithreading download
|
105
|
+
test_files: []
|
106
|
+
|