my-local-putio 1.0.1 → 2.0.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 +9 -0
- data/README.md +12 -12
- data/lib/my-local-putio.rb +2 -2
- data/lib/my-local-putio/configuration.rb +6 -6
- data/lib/my-local-putio/fetcher.rb +2 -2
- data/lib/my-local-putio/logger.rb +9 -5
- data/lib/my-local-putio/putio_cli.rb +0 -6
- data/lib/my-local-putio/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1fda62376b386445ef3068eeedc6709cd81d8b51d858ff74f9217a4437c1408
|
4
|
+
data.tar.gz: cf24f1efbaf4d1f0c8524cf2f07f47f56e5935df823eceb2eb0d8ba32b22473a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ab8bb987a3ad33f15e97cac86823c51d70a3f95552c0ccf5790fb1622fcdcd4c40209b58003d0facdf7b366b021d579022f0b8f7450703145db484e660c7c94
|
7
|
+
data.tar.gz: 7dd182463935fbce5ccae3c447f473b13f2df3a3f60fd85bba1775d39bc9fc871701c66a503a9a797eebc986a4fa0c6a9ca0059f9235bf91a27d786ac9daa22d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# v2.0.0
|
2
|
+
|
3
|
+
- Breaking changes parameters
|
4
|
+
- --verbose (-v) was removed. By default all messages will be printed out.
|
5
|
+
- --silent option was introduced to mute the output.
|
6
|
+
- --destination (-d) was removed and replaced by --local-destination
|
7
|
+
- introduced -d option for --debug
|
8
|
+
|
9
|
+
|
1
10
|
# v1.0.1
|
2
11
|
|
3
12
|
- Fixing small require bug
|
data/README.md
CHANGED
@@ -38,19 +38,19 @@ For now the script only supports download the content from your account and keep
|
|
38
38
|
my-local-putio -h
|
39
39
|
|
40
40
|
Usage: my-local-putio [options]
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
--debug Debug mode [Developer mode]
|
41
|
+
-t, --token TOKEN Put.io access token [REQUIRED]
|
42
|
+
-l, --local-destination PATH Local destination path [REQUIRED]
|
43
|
+
-s, --silent Hide all messages and progress bar
|
44
|
+
-d, --debug Debug mode [Developer mode]
|
45
45
|
|
46
46
|
#### Required attributes:
|
47
47
|
* **-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.
|
48
|
-
* **-
|
48
|
+
* **-l** or **--local-destination**: Local destination folder
|
49
49
|
|
50
50
|
Examples:
|
51
51
|
|
52
|
-
my-local-putio -t 123 -
|
53
|
-
my-local-putio -
|
52
|
+
my-local-putio -t 123 -l Downloads
|
53
|
+
my-local-putio -l Downloads --token 123
|
54
54
|
|
55
55
|
With Token variable (inline or exporting):
|
56
56
|
|
@@ -61,15 +61,15 @@ With Token variable (inline or exporting):
|
|
61
61
|
|
62
62
|
#### Others attributes:
|
63
63
|
* **-h**: Print the help usage message
|
64
|
-
* **-
|
65
|
-
* **--debug**: Developer mode: Prints everything
|
64
|
+
* **-s** or **--silent**: Hide all messages and progress bar
|
65
|
+
* **-d** or **--debug**: Developer mode: Prints everything and expose URLs with tokens for debug purposes.
|
66
66
|
|
67
67
|
Examples:
|
68
68
|
|
69
69
|
my-local-putio -h
|
70
|
-
my-local-putio -t 123 -
|
71
|
-
my-local-putio -t 123 -
|
72
|
-
my-local-putio --destination Downloads -t 123 --debug
|
70
|
+
my-local-putio -t 123 -l Downloads --silent
|
71
|
+
my-local-putio -t 123 -l Downloads -s
|
72
|
+
my-local-putio --local-destination Downloads -t 123 --debug
|
73
73
|
|
74
74
|
Verbose output example:
|
75
75
|
|
data/lib/my-local-putio.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Put.io
|
1
|
+
# My Local Put.io
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# The easiest script to synchronise all your put.io files locally.
|
4
4
|
#
|
5
5
|
# Created by: Rafael Biriba - biribarj@gmail.com
|
6
6
|
# More info: https://github.com/rafaelbiriba/my-local-putio
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module MyLocalPutio
|
2
2
|
class Configuration
|
3
|
-
attr_reader :token, :
|
3
|
+
attr_reader :token, :local_destination, :silent, :debug
|
4
4
|
def initialize
|
5
5
|
read_args_from_envs!
|
6
6
|
parse_args!
|
@@ -11,9 +11,9 @@ module MyLocalPutio
|
|
11
11
|
def parse_args!
|
12
12
|
OptionParser.new do |opt|
|
13
13
|
opt.on("-t", "--token TOKEN", "Put.io access token [REQUIRED]") { |v| @token = v }
|
14
|
-
opt.on("-
|
15
|
-
opt.on("-
|
16
|
-
opt.on("--debug", "Debug mode [Developer mode]") { |v| @debug = true }
|
14
|
+
opt.on("-l", "--local-destination PATH", "Local destination path [REQUIRED]") { |v| @local_destination = v }
|
15
|
+
opt.on("-s", "--silent", "Hide all messages and progress bar") { |v| @silent = true }
|
16
|
+
opt.on("-d", "--debug", "Debug mode [Developer mode]") { |v| @debug = true }
|
17
17
|
end.parse!
|
18
18
|
end
|
19
19
|
|
@@ -22,8 +22,8 @@ module MyLocalPutio
|
|
22
22
|
raise OptionParser::MissingArgument.new("--token")
|
23
23
|
end
|
24
24
|
|
25
|
-
unless @
|
26
|
-
raise OptionParser::MissingArgument.new("--destination")
|
25
|
+
unless @local_destination
|
26
|
+
raise OptionParser::MissingArgument.new("--local-destination")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -12,7 +12,7 @@ module MyLocalPutio
|
|
12
12
|
|
13
13
|
protected
|
14
14
|
|
15
|
-
def fetch_files(id: nil, path: configuration.
|
15
|
+
def fetch_files(id: nil, path: configuration.local_destination)
|
16
16
|
FileUtils.mkdir_p(path)
|
17
17
|
logger.log "Getting files for #{path}"
|
18
18
|
files = cli.get_files(id)["files"]
|
@@ -40,7 +40,7 @@ module MyLocalPutio
|
|
40
40
|
command = [
|
41
41
|
"curl", "--progress-bar", "-L", "--retry", "5", "-S", "-C", "-", "-o", path, url.to_s
|
42
42
|
]
|
43
|
-
command.push("--silent")
|
43
|
+
command.push("--silent") if logger.silent?
|
44
44
|
system(*command)
|
45
45
|
end
|
46
46
|
end
|
@@ -6,8 +6,8 @@ module MyLocalPutio
|
|
6
6
|
@configuration = configuration
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
configuration.
|
9
|
+
def silent?
|
10
|
+
configuration.silent
|
11
11
|
end
|
12
12
|
|
13
13
|
def debug?
|
@@ -16,16 +16,20 @@ module MyLocalPutio
|
|
16
16
|
|
17
17
|
def debug(msg)
|
18
18
|
return unless debug?
|
19
|
-
|
19
|
+
print_msg "[DEBUG][#{time_now}] #{msg}"
|
20
20
|
end
|
21
21
|
|
22
22
|
def log(msg)
|
23
|
-
|
24
|
-
puts "[LOG][#{time_now}] #{msg}"
|
23
|
+
print_msg "[LOG][#{time_now}] #{msg}"
|
25
24
|
end
|
26
25
|
|
27
26
|
private
|
28
27
|
|
28
|
+
def print_msg(msg)
|
29
|
+
return if silent?
|
30
|
+
puts msg
|
31
|
+
end
|
32
|
+
|
29
33
|
def time_now
|
30
34
|
Time.now.strftime("%F %H:%M:%S")
|
31
35
|
end
|
@@ -16,7 +16,6 @@ module MyLocalPutio
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def get_download_url(id)
|
19
|
-
# Follow redirect plz
|
20
19
|
url = to_url("files/#{id}/download")
|
21
20
|
url.query = URI.encode_www_form to_args()
|
22
21
|
url
|
@@ -24,11 +23,6 @@ module MyLocalPutio
|
|
24
23
|
|
25
24
|
protected
|
26
25
|
|
27
|
-
def log(msg)
|
28
|
-
return unless configuration.verbose
|
29
|
-
puts msg
|
30
|
-
end
|
31
|
-
|
32
26
|
def get(path, args={})
|
33
27
|
url = to_url(path)
|
34
28
|
url.query = URI.encode_www_form to_args(args)
|