my-local-putio 3.0.1 → 4.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 +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +21 -19
- data/lib/my-local-putio.rb +3 -0
- data/lib/my-local-putio/configuration.rb +3 -2
- data/lib/my-local-putio/downloader.rb +36 -0
- data/lib/my-local-putio/fetcher.rb +7 -28
- data/lib/my-local-putio/putio_cli.rb +2 -4
- data/lib/my-local-putio/subtitles_manager.rb +45 -0
- data/lib/my-local-putio/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbfff6a7128d63370560d6453a34a9f65cdc019c2cec8dfbaa42715ff776867e
|
4
|
+
data.tar.gz: e147047592191b5cfe4127a81f63ecdc5851baf660fd90a1d5eb3e1fa7c0d91b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3a239f681fcfde6f087c7782607e89b6cfef19eb6dd99781f986d85b75aed5ab91c96c6a74f42ea7db4ae40c3243ed20035270a5f3f2ce527c67f85970ff6b0
|
7
|
+
data.tar.gz: b5384e46713dd9e63bb09dd8156df491902077096b053d4bcc45df855c8e2ba251ea43c9f3bb651eafad7334a38615291ef34bbd48d5afe3f87de31aff59a98f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# v4.0.0
|
2
|
+
|
3
|
+
- Introducing with subtitles option
|
4
|
+
- Breaking changes parameters
|
5
|
+
- removed -s option for --silent. Now silent is only available as --silent
|
6
|
+
- introduced -s option for --with-subtitles
|
7
|
+
- More code refactoring
|
8
|
+
|
1
9
|
# v3.0.1
|
2
10
|
|
3
11
|
- Fix for delete-remote that was not enabling/disabling properly.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -3,23 +3,17 @@ My Local Put.io [![Gem Version](https://badge.fury.io/rb/my-local-putio.svg)](ht
|
|
3
3
|
|
4
4
|
The easiest script to synchronize all your [Put.io](http://put.io) files locally.
|
5
5
|
|
6
|
-
|
6
|
+
After the download, you can enable the option to remove the files from Put.io and also download your preferred subtitles if available in Put.io.
|
7
7
|
|
8
8
|
### Features
|
9
9
|
|
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.
|
10
|
+
- Check and skip already downloaded files.
|
12
11
|
- Resume broken/stopped downloads, so you don't have to start from the begin of your huge file.
|
13
|
-
-
|
12
|
+
- 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.
|
14
13
|
- Option to delete the file from put.io after the download
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
- Option to download the subtitle if available in put.io list
|
19
|
-
|
20
|
-
#### Future or ideas: (Feel free to contribute to the list)
|
21
|
-
|
22
|
-
- Add a magnet/torrent to the put.io account based on local files or references.
|
14
|
+
- Option to download your preferred subtitles from Put.io.
|
15
|
+
- Simple and easy to run
|
16
|
+
- For free and forever free :)
|
23
17
|
|
24
18
|
## Copyright Disclaimer
|
25
19
|
|
@@ -30,10 +24,14 @@ For now the script only supports download the content from your account and keep
|
|
30
24
|
|
31
25
|
* Install ruby 2.6.0+
|
32
26
|
* Generate a token for your put.io account: https://app.put.io/authenticate?client_id=1&response_type=oob
|
33
|
-
* Install the `my-local-putio` gem:
|
27
|
+
* Install the latest version of `my-local-putio` gem:
|
34
28
|
|
35
29
|
gem install my-local-putio
|
36
30
|
|
31
|
+
To update your installed version:
|
32
|
+
|
33
|
+
gem update my-local-putio
|
34
|
+
|
37
35
|
## Usage
|
38
36
|
|
39
37
|
my-local-putio -h
|
@@ -42,8 +40,9 @@ For now the script only supports download the content from your account and keep
|
|
42
40
|
-t, --token TOKEN Put.io access token [REQUIRED]
|
43
41
|
-l, --local-destination PATH Local destination path [REQUIRED]
|
44
42
|
-d, --delete-remote Delete remote file/folder after the download
|
43
|
+
-s, --with-subtitles Fetch subtitles from Put.io api
|
45
44
|
-v, --version Print my-local-putio version
|
46
|
-
|
45
|
+
--silent Hide all messages and progress bar
|
47
46
|
--debug Debug mode [Developer mode]
|
48
47
|
--socks5-proxy hostname:port SOCKS5 hostname and port for proxy. Format: 127.0.0.1:1234
|
49
48
|
|
@@ -55,6 +54,7 @@ Examples:
|
|
55
54
|
|
56
55
|
my-local-putio -t 123 -l Downloads
|
57
56
|
my-local-putio -l Downloads --token 123
|
57
|
+
my-local-putio -l Downloads -t token123 -d -s --socks5-proxy 127.0.0.1:1234
|
58
58
|
|
59
59
|
With Token variable (inline or exporting):
|
60
60
|
|
@@ -65,29 +65,31 @@ With Token variable (inline or exporting):
|
|
65
65
|
|
66
66
|
#### Others attributes:
|
67
67
|
* **-d** or **--delete-remote**: Delete the remote file/folder from put.io after downloading
|
68
|
+
* **-s** or **--with-subtitles**: Download subtitles from Put.io API if available. (Remember to set your preferred subtitle language on Put.io Settings website, otherwise no subtitle will be available for download.)
|
68
69
|
* **-h**: Print the help usage message
|
69
70
|
* **-v** or **--version**: Print the version of the application
|
70
|
-
*
|
71
|
+
* **--silent**: Hide all messages and progress bar. Recommended for Cronjob tasks.
|
71
72
|
* **--debug**: Developer mode: Prints everything and expose URLs with tokens for debug purposes.
|
72
73
|
* **--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.
|
73
74
|
|
74
75
|
Examples:
|
75
76
|
|
76
77
|
my-local-putio -h
|
77
|
-
my-local-putio -t 123 -l Downloads --silent -d
|
78
|
-
my-local-putio -t 123 -l Downloads
|
79
|
-
my-local-putio --local-destination Downloads -t 123 --debug
|
78
|
+
my-local-putio -t 123 -l Downloads --silent -d -s
|
79
|
+
my-local-putio -t 123 -l Downloads --silent
|
80
|
+
my-local-putio --local-destination Downloads -t 123 --debug --with-subtitles
|
80
81
|
my-local-putio --local-destination Downloads -t 123 --socks5-proxy 127.0.0.1:3333
|
81
82
|
|
82
83
|
Verbose output example:
|
83
84
|
|
84
|
-
my-local-putio -t 123 -l Downloads -d --socks5-proxy 127.0.0.1:3333
|
85
|
+
my-local-putio -t 123 -l Downloads -d -s --socks5-proxy 127.0.0.1:3333
|
85
86
|
|
86
87
|
Starting My Local Put.io - version 3.0.0
|
87
88
|
https://github.com/rafaelbiriba/my-local-putio
|
88
89
|
=============================================
|
89
90
|
Full path of the local destination: /Users/user/Downloads
|
90
91
|
>>> Delete remote files enabled!
|
92
|
+
>>> With subtitles enabled!
|
91
93
|
>>> SOCKS5 enabled with 127.0.0.1:3333
|
92
94
|
=============================================
|
93
95
|
[LOG][2019-07-18 11:11:30] Getting file list for /
|
data/lib/my-local-putio.rb
CHANGED
@@ -24,6 +24,8 @@ require "my-local-putio/configuration"
|
|
24
24
|
require "my-local-putio/logger"
|
25
25
|
require "my-local-putio/putio_cli"
|
26
26
|
require "my-local-putio/fetcher"
|
27
|
+
require "my-local-putio/downloader"
|
28
|
+
require "my-local-putio/subtitles_manager"
|
27
29
|
|
28
30
|
module MyLocalPutio
|
29
31
|
def self.print_introduction_msg(configuration)
|
@@ -33,6 +35,7 @@ module MyLocalPutio
|
|
33
35
|
puts "============================================="
|
34
36
|
puts "Full path of the local destination: #{File.realdirpath(configuration.local_destination)}"
|
35
37
|
puts ">>> Delete remote files enabled!" if configuration.delete_remote
|
38
|
+
puts ">>> With subtitles enabled!" if configuration.with_subtitles
|
36
39
|
puts ">>> SOCKS5 enabled with #{configuration.socks_host}:#{configuration.socks_port}" if configuration.socks_enabled?
|
37
40
|
puts ">>> DEBUG enabled! Hello Mr(s) developer :)" if configuration.debug
|
38
41
|
puts "============================================="
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module MyLocalPutio
|
2
2
|
class Configuration
|
3
|
-
attr_reader :token, :local_destination, :silent, :debug, :socks_host, :socks_port, :delete_remote
|
3
|
+
attr_reader :token, :local_destination, :silent, :debug, :socks_host, :socks_port, :delete_remote, :with_subtitles
|
4
4
|
def initialize
|
5
5
|
read_args_from_envs!
|
6
6
|
parse_args!
|
@@ -21,12 +21,13 @@ module MyLocalPutio
|
|
21
21
|
opt.on("-t", "--token TOKEN", "Put.io access token [REQUIRED]") { |v| @token = v }
|
22
22
|
opt.on("-l", "--local-destination PATH", "Local destination path [REQUIRED]") { |v| @local_destination = v }
|
23
23
|
opt.on("-d", "--delete-remote", "Delete remote file/folder after the download") { |v| @delete_remote = true }
|
24
|
+
opt.on("-s", "--with-subtitles", "Fetch subtitles from Put.io api") { |v| @with_subtitles = true }
|
24
25
|
opt.on("-v", "--version", "Print my-local-putio version") do
|
25
26
|
puts MyLocalPutio::VERSION
|
26
27
|
exit
|
27
28
|
end
|
28
29
|
|
29
|
-
opt.on("
|
30
|
+
opt.on("--silent", "Hide all messages and progress bar") { |v| @silent = true }
|
30
31
|
opt.on("--debug", "Debug mode [Developer mode]") { |v| @debug = true }
|
31
32
|
opt.on("--socks5-proxy hostname:port", "SOCKS5 hostname and port for proxy. Format: 127.0.0.1:1234") do |v|
|
32
33
|
@socks_host, @socks_port = v.to_s.split(":")
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module MyLocalPutio
|
2
|
+
class Downloader
|
3
|
+
attr_reader :configuration, :logger
|
4
|
+
|
5
|
+
def initialize(configuration)
|
6
|
+
@configuration = configuration
|
7
|
+
@logger = configuration.logger
|
8
|
+
end
|
9
|
+
|
10
|
+
def download(url, path)
|
11
|
+
logger.debug "Download file from #{url}"
|
12
|
+
logger.log "Downloading: #{path}"
|
13
|
+
command = download_command(url, path)
|
14
|
+
fetch_result = system(*command)
|
15
|
+
raise "Unable to download #{path}" unless fetch_result
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def download_command(url, path)
|
21
|
+
destination = File.join(configuration.local_destination, path)
|
22
|
+
|
23
|
+
command = [
|
24
|
+
"curl", "--create-dirs", "--progress-bar", "-L", "--retry", "5", "-S", "-C", "-", "-o", destination, url.to_s
|
25
|
+
]
|
26
|
+
|
27
|
+
command.push("--silent") if logger.silent?
|
28
|
+
|
29
|
+
if configuration.socks_enabled?
|
30
|
+
command.push("--socks5-hostname", "#{configuration.socks_host}:#{configuration.socks_port}")
|
31
|
+
end
|
32
|
+
|
33
|
+
return command
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,18 +1,19 @@
|
|
1
1
|
module MyLocalPutio
|
2
2
|
class Fetcher
|
3
|
-
attr_reader :configuration, :cli, :logger
|
3
|
+
attr_reader :configuration, :cli, :logger, :downloader
|
4
4
|
|
5
5
|
def initialize(configuration)
|
6
6
|
@configuration = configuration
|
7
7
|
@logger = configuration.logger
|
8
8
|
@cli = PutioCli.new(@configuration)
|
9
|
+
@downloader = Downloader.new(@configuration)
|
9
10
|
end
|
10
11
|
|
11
12
|
def run!
|
12
13
|
fetch_files
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
+
private
|
16
17
|
|
17
18
|
def fetch_files(id: nil, path: "/")
|
18
19
|
logger.log "Getting remote file list for #{path}"
|
@@ -29,13 +30,15 @@ module MyLocalPutio
|
|
29
30
|
if file.content_type == "application/x-directory"
|
30
31
|
fetch_files(id: file.id, path: local_file_path)
|
31
32
|
else
|
32
|
-
|
33
|
-
|
33
|
+
url = cli.get_download_url(file.id)
|
34
|
+
Downloader.new(@configuration).download(url, local_file_path) unless file_exists?(local_file_path, file)
|
35
|
+
SubtitlesManager.new(configuration).fetch(file, path)
|
34
36
|
end
|
35
37
|
delete_file(local_file_path, file)
|
36
38
|
end
|
37
39
|
|
38
40
|
def delete_file(local_file_path, file)
|
41
|
+
return unless configuration.delete_remote
|
39
42
|
logger.log "Deleting remote file: #{local_file_path}"
|
40
43
|
cli.delete_file(file.id)
|
41
44
|
end
|
@@ -45,29 +48,5 @@ module MyLocalPutio
|
|
45
48
|
logger.log "File already downloaded #{local_file_path}" if file_exists
|
46
49
|
file_exists
|
47
50
|
end
|
48
|
-
|
49
|
-
def download_command(url, path)
|
50
|
-
destination = File.join(configuration.local_destination, path)
|
51
|
-
|
52
|
-
command = [
|
53
|
-
"curl", "--create-dirs", "--progress-bar", "-L", "--retry", "5", "-S", "-C", "-", "-o", destination, url.to_s
|
54
|
-
]
|
55
|
-
|
56
|
-
command.push("--silent") if logger.silent?
|
57
|
-
|
58
|
-
if configuration.socks_enabled?
|
59
|
-
command.push("--socks5-hostname", "#{configuration.socks_host}:#{configuration.socks_port}")
|
60
|
-
end
|
61
|
-
|
62
|
-
return command
|
63
|
-
end
|
64
|
-
|
65
|
-
def download(file, path)
|
66
|
-
url = cli.get_download_url(file.id)
|
67
|
-
command = download_command(url, path)
|
68
|
-
logger.log "Downloading: #{path}"
|
69
|
-
fetch_result = system(*command)
|
70
|
-
raise "Unable to download #{path}" unless fetch_result
|
71
|
-
end
|
72
51
|
end
|
73
52
|
end
|
@@ -20,10 +20,8 @@ module MyLocalPutio
|
|
20
20
|
post("files/delete", args)
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
25
|
-
url.query = URI.encode_www_form to_args()
|
26
|
-
url
|
23
|
+
def get_subtitles(id)
|
24
|
+
get("files/#{id}/subtitles")
|
27
25
|
end
|
28
26
|
|
29
27
|
def get_download_url(id)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module MyLocalPutio
|
2
|
+
class SubtitlesManager
|
3
|
+
attr_reader :configuration, :logger, :cli, :downloader
|
4
|
+
|
5
|
+
def initialize(configuration)
|
6
|
+
@configuration = configuration
|
7
|
+
@logger = configuration.logger
|
8
|
+
@cli = PutioCli.new(@configuration)
|
9
|
+
@downloader = Downloader.new(@configuration)
|
10
|
+
end
|
11
|
+
|
12
|
+
def fetch(file, path)
|
13
|
+
return unless configuration.with_subtitles
|
14
|
+
return unless file_is_video?(file)
|
15
|
+
|
16
|
+
local_subtitle_path = File.join(path, filename(file))
|
17
|
+
logger.log "Trying to fetch the preferred subtitle for: #{file.name}"
|
18
|
+
subtitles = cli.get_subtitles(file.id)["subtitles"]
|
19
|
+
if subtitles.empty?
|
20
|
+
logger.log ":( Could not find any preferred subtitle for: #{file.name}"
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
process_subtitle(subtitles, local_subtitle_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def filename(file)
|
29
|
+
File.basename(file.name, File.extname(file.name))
|
30
|
+
end
|
31
|
+
|
32
|
+
def file_is_video?(file)
|
33
|
+
file.file_type == "VIDEO"
|
34
|
+
end
|
35
|
+
|
36
|
+
def process_subtitle(subtitles, local_subtitle_path)
|
37
|
+
subtitles_grouped = subtitles.group_by{|k,v| k["language_code"]}
|
38
|
+
subtitles_grouped.each do |language_code, list|
|
39
|
+
path = local_subtitle_path + ".#{language_code}.srt"
|
40
|
+
logger.log("#{list.first["language"]} subtitle found!")
|
41
|
+
downloader.download(list.first["url"], path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my-local-putio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Biriba
|
@@ -70,9 +70,11 @@ files:
|
|
70
70
|
- bin/my-local-putio
|
71
71
|
- lib/my-local-putio.rb
|
72
72
|
- lib/my-local-putio/configuration.rb
|
73
|
+
- lib/my-local-putio/downloader.rb
|
73
74
|
- lib/my-local-putio/fetcher.rb
|
74
75
|
- lib/my-local-putio/logger.rb
|
75
76
|
- lib/my-local-putio/putio_cli.rb
|
77
|
+
- lib/my-local-putio/subtitles_manager.rb
|
76
78
|
- lib/my-local-putio/version.rb
|
77
79
|
- my-local-putio.gemspec
|
78
80
|
homepage: https://github.com/rafaelbiriba/my-local-putio
|