my-local-putio 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +3 -1
- data/README.md +9 -3
- data/lib/my-local-putio.rb +2 -0
- data/lib/my-local-putio/configuration.rb +31 -3
- data/lib/my-local-putio/fetcher.rb +6 -0
- data/lib/my-local-putio/putio_cli.rb +9 -1
- data/lib/my-local-putio/version.rb +1 -1
- data/my-local-putio.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebd963a16897bd822f3d645dc96c195ed9c2ab6e0d10c7e3105e8f5f1c9a31bb
|
4
|
+
data.tar.gz: 20504d68d91dee34108c6b3f57253d1a522b25be9c250935459727c5b218ccdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 320d88bcf89dc9e86ac7f0ce7822148b5599424c5177ac9033cfea2efb2016d2e5740d7e693b968deddb2da68ae18ab5c7497a9b17af407222c37e45e9e1461e
|
7
|
+
data.tar.gz: 2651b2609fd2943ac205d81eeead93662b28a3b0072873649d2cb95b5afa9b4471a41eb2455710ecf4b8875c621eed05e2e3eaa32d127461c2d27ce5ec27ae53
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
My Local Put.io
|
1
|
+
My Local Put.io [![Gem Version](https://badge.fury.io/rb/my-local-putio.svg)](http://badge.fury.io/rb/my-local-putio) [![Code Climate](https://codeclimate.com/github/rafaelbiriba/my-local-putio/badges/gpa.svg)](https://codeclimate.com/github/rafaelbiriba/my-local-putio)
|
2
2
|
===========
|
3
3
|
|
4
4
|
The easiest script to synchronize all your [Put.io](http://put.io) files locally.
|
@@ -8,6 +8,7 @@ For now the script only supports download the content from your account and keep
|
|
8
8
|
### Features
|
9
9
|
|
10
10
|
- Check and skip already downloaded files
|
11
|
+
- Supports SOCKS5 proxy for an even more secure and anonymous transfer, with kill switch, so the application will stop if the proxy became unavailable. No leak connections.
|
11
12
|
- Resume broken/stopped downloads, so you don't have to start from the begin of your huge file.
|
12
13
|
- Simple and easy to run
|
13
14
|
|
@@ -40,8 +41,10 @@ For now the script only supports download the content from your account and keep
|
|
40
41
|
Usage: my-local-putio [options]
|
41
42
|
-t, --token TOKEN Put.io access token [REQUIRED]
|
42
43
|
-l, --local-destination PATH Local destination path [REQUIRED]
|
44
|
+
-v, --version Print my-local-putio version
|
43
45
|
-s, --silent Hide all messages and progress bar
|
44
46
|
-d, --debug Debug mode [Developer mode]
|
47
|
+
--socks5-proxy hostname:port SOCKS5 hostname and port for proxy. Format: 127.0.0.1:1234
|
45
48
|
|
46
49
|
#### Required attributes:
|
47
50
|
* **-t** or **--token**: Your Put.io Token. This attribute becames optional if you set `PUTIO_TOKEN` env variable with your token (Can be inline or into your bash profile). Check examples below.
|
@@ -54,15 +57,17 @@ Examples:
|
|
54
57
|
|
55
58
|
With Token variable (inline or exporting):
|
56
59
|
|
57
|
-
PUTIO_TOKEN=123 my-local-putio -
|
60
|
+
PUTIO_TOKEN=123 my-local-putio -l Downloads
|
58
61
|
|
59
62
|
export PUTIO_TOKEN=123
|
60
|
-
my-local-putio -
|
63
|
+
my-local-putio --local-destination Downloads/
|
61
64
|
|
62
65
|
#### Others attributes:
|
63
66
|
* **-h**: Print the help usage message
|
67
|
+
* **-v** or **--version**: Print the version of the application
|
64
68
|
* **-s** or **--silent**: Hide all messages and progress bar
|
65
69
|
* **-d** or **--debug**: Developer mode: Prints everything and expose URLs with tokens for debug purposes.
|
70
|
+
* **--socks5-proxy**: Enable the SOCKS5 proxy. If enabled, all the connections for PUT.IO API and the downloads will be performed using this proxy. If the socks connection became unavailable, the application will raise an error and will stop.
|
66
71
|
|
67
72
|
Examples:
|
68
73
|
|
@@ -70,6 +75,7 @@ Examples:
|
|
70
75
|
my-local-putio -t 123 -l Downloads --silent
|
71
76
|
my-local-putio -t 123 -l Downloads -s
|
72
77
|
my-local-putio --local-destination Downloads -t 123 --debug
|
78
|
+
my-local-putio --local-destination Downloads -t 123 --socks5-proxy 127.0.0.1:3333
|
73
79
|
|
74
80
|
Verbose output example:
|
75
81
|
|
data/lib/my-local-putio.rb
CHANGED
@@ -1,34 +1,62 @@
|
|
1
1
|
module MyLocalPutio
|
2
2
|
class Configuration
|
3
|
-
attr_reader :token, :local_destination, :silent, :debug
|
3
|
+
attr_reader :token, :local_destination, :silent, :debug, :socks_host, :socks_port
|
4
4
|
def initialize
|
5
5
|
read_args_from_envs!
|
6
6
|
parse_args!
|
7
7
|
validate_args!
|
8
8
|
end
|
9
9
|
|
10
|
+
def socks_enabled?
|
11
|
+
@socks_host || @socks_port
|
12
|
+
end
|
13
|
+
|
10
14
|
private
|
11
15
|
def parse_args!
|
12
16
|
OptionParser.new do |opt|
|
13
17
|
opt.on("-t", "--token TOKEN", "Put.io access token [REQUIRED]") { |v| @token = v }
|
14
18
|
opt.on("-l", "--local-destination PATH", "Local destination path [REQUIRED]") { |v| @local_destination = v }
|
19
|
+
opt.on("-v", "--version", "Print my-local-putio version") do
|
20
|
+
puts MyLocalPutio::VERSION
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
15
24
|
opt.on("-s", "--silent", "Hide all messages and progress bar") { |v| @silent = true }
|
16
25
|
opt.on("-d", "--debug", "Debug mode [Developer mode]") { |v| @debug = true }
|
26
|
+
opt.on("--socks5-proxy hostname:port", "SOCKS5 hostname and port for proxy. Format: 127.0.0.1:1234") do |v|
|
27
|
+
@socks_host, @socks_port = v.to_s.split(":")
|
28
|
+
end
|
17
29
|
end.parse!
|
18
30
|
end
|
19
31
|
|
20
32
|
def validate_args!
|
21
33
|
unless @token
|
22
|
-
|
34
|
+
puts "Missing token"
|
35
|
+
exit
|
23
36
|
end
|
24
37
|
|
25
38
|
unless @local_destination
|
26
|
-
|
39
|
+
puts "Missing local destination"
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
|
43
|
+
unless File.writable?(@local_destination)
|
44
|
+
puts "Cannot write on the local destination path '#{@local_destination}'"
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
|
48
|
+
if socks_enabled? && !port_is_open?(@socks_host, @socks_port)
|
49
|
+
puts "Cannot connect to socks using '#{@socks_host}:#{@socks_port}'"
|
50
|
+
exit
|
27
51
|
end
|
28
52
|
end
|
29
53
|
|
30
54
|
def read_args_from_envs!
|
31
55
|
@token ||= ENV["PUTIO_TOKEN"]
|
32
56
|
end
|
57
|
+
|
58
|
+
def port_is_open?(host, port)
|
59
|
+
Socket.tcp(host, port, connect_timeout: 5) { true } rescue false
|
60
|
+
end
|
33
61
|
end
|
34
62
|
end
|
@@ -40,7 +40,13 @@ module MyLocalPutio
|
|
40
40
|
command = [
|
41
41
|
"curl", "--progress-bar", "-L", "--retry", "5", "-S", "-C", "-", "-o", path, url.to_s
|
42
42
|
]
|
43
|
+
|
43
44
|
command.push("--silent") if logger.silent?
|
45
|
+
|
46
|
+
if configuration.socks_enabled?
|
47
|
+
command.push("--socks5-hostname", "#{configuration.socks_host}:#{configuration.socks_port}")
|
48
|
+
end
|
49
|
+
|
44
50
|
system(*command)
|
45
51
|
end
|
46
52
|
end
|
@@ -5,7 +5,7 @@ module MyLocalPutio
|
|
5
5
|
|
6
6
|
def initialize(configuration, endpoint=ROOT, logger)
|
7
7
|
@configuration, @endpoint, @logger = configuration, URI(endpoint), logger
|
8
|
-
@http =
|
8
|
+
@http = http_library.new(@endpoint.host, @endpoint.port)
|
9
9
|
@http.use_ssl = true
|
10
10
|
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
11
11
|
end
|
@@ -23,6 +23,14 @@ module MyLocalPutio
|
|
23
23
|
|
24
24
|
protected
|
25
25
|
|
26
|
+
def http_library
|
27
|
+
if @configuration.socks_enabled?
|
28
|
+
Net::HTTP::SOCKSProxy(@configuration.socks_host, @configuration.socks_port)
|
29
|
+
else
|
30
|
+
Net::HTTP
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
26
34
|
def get(path, args={})
|
27
35
|
url = to_url(path)
|
28
36
|
url.query = URI.encode_www_form to_args(args)
|
data/my-local-putio.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my-local-putio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Biriba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: socksify
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.7.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.7.1
|
41
55
|
description: The easiest script to synchronise all your put.io files locally.
|
42
56
|
email:
|
43
57
|
- biribarj@gmail.com
|