my-local-putio 4.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f91c9ff297300ac8c7da30e3949fe7053e1da07ea0d7bba109000aa097a5323
4
- data.tar.gz: bef0b5f1fca0e7bc6bb8f3b0a4efcb86285ed3d7bc60b14da685fd188c0bcd6e
3
+ metadata.gz: 1fda9ccd9e21d1f3028968ec7a14e6457053553910740739fba4f5b56d39ea47
4
+ data.tar.gz: d9299607c186f5c6cdb339c0e3d5a3e2075af67dc2ef3243fc0e282df65723d4
5
5
  SHA512:
6
- metadata.gz: 33e606fdb602ff6c1a1f8ce7bfb087d6f358cfd86ba8da42f15249d4253c05a92f0d3a8d5b21035086b826311716471c489645a166044330204e7823e3bcc6df
7
- data.tar.gz: f1886e6ac88f4e1f7405388a6a85ead14082e2c81e47dd39b82c97f3aa70a6ba9d419ac9d36b965e2b23b9c1ebafff3eb66ad51fcea096b8ee4baba014fc8ad7
6
+ metadata.gz: 0f4facdcd383dfc2c0f3a2e85e04617bf15c23b35a149a0f6686353406e15c3f96dc60588417f0858b65a7972674158a1b221d8053e8df84ce5e3c7c0bc3ba77
7
+ data.tar.gz: 6497ba264ee6de19adfa927adb54ca118ec4a22993e6c37753277a3383b9ad5be7df04457574e67c9a097d742fa0f41828c3070be976004db1f4878bfe83ebe3
@@ -1,3 +1,8 @@
1
+ # v4.3.0
2
+
3
+ - Introducing --disk-threshold
4
+ - Check if there is enough space on the disk (download/temporary folder) before download another file
5
+
1
6
  # v4.2.0
2
7
 
3
8
  - Introducing temporary destination
@@ -7,7 +7,7 @@ PATH
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- rake (10.5.0)
10
+ rake (13.0.1)
11
11
  socksify (1.7.1)
12
12
 
13
13
  PLATFORMS
@@ -16,7 +16,7 @@ PLATFORMS
16
16
  DEPENDENCIES
17
17
  bundler (~> 2.0)
18
18
  my-local-putio!
19
- rake (~> 10.0)
19
+ rake (~> 13.0)
20
20
 
21
21
  BUNDLED WITH
22
22
  2.0.2
data/README.md CHANGED
@@ -46,6 +46,7 @@ To update your installed version:
46
46
  --silent Hide all messages and progress bar
47
47
  --debug Debug mode [Developer mode]
48
48
  --socks5-proxy hostname:port SOCKS5 hostname and port for proxy. Format: 127.0.0.1:1234
49
+ --disk-threshold size Stops the downloads when the disk space threshold is reached. (Size in MB, e.g: 2000 for 2GB)
49
50
 
50
51
  #### Required attributes:
51
52
  * **-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.
@@ -56,6 +57,7 @@ Examples:
56
57
  my-local-putio -t 123 -l Downloads
57
58
  my-local-putio -l Downloads --token 123
58
59
  my-local-putio -l Downloads -t token123 -d -s --socks5-proxy 127.0.0.1:1234
60
+ my-local-putio -d -s --disk-threshold size 1000
59
61
 
60
62
  With Token variable (inline or exporting):
61
63
 
@@ -73,6 +75,7 @@ With Token variable (inline or exporting):
73
75
  * **--silent**: Hide all messages and progress bar. Recommended for Cronjob tasks.
74
76
  * **--debug**: Developer mode: Prints everything and expose URLs with tokens for debug purposes.
75
77
  * **--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.
78
+ * **--disk-threshold**: Set a disk threshold **(in MB)** to prevent the script to fill up the entire disk. The threshold value is in MB **(e.g 1000 for 1GB)**. The script will test both download folder and temporary folder to detect if there is enough space before download each file. If the free space is less than (file size + disk threshold) the script will stop. (Example: If the folder have 10GB available, and the threshold is set to 2GB (2000), the script will stop before start downloading a file with 9GB size)
76
79
 
77
80
  Examples:
78
81
 
@@ -82,19 +85,21 @@ Examples:
82
85
  my-local-putio -l Downloads -t 123 --temp-destination /tmp --with-subtitles
83
86
  my-local-putio --local-destination Downloads -t 123 --debug --with-subtitles
84
87
  my-local-putio --local-destination Downloads -t 123 --socks5-proxy 127.0.0.1:3333
88
+ my-local-putio -d -s --disk-threshold size 1000
85
89
 
86
90
  Verbose output example:
87
91
 
88
- my-local-putio -t 123 -l Downloads -d -s --socks5-proxy 127.0.0.1:3333 --temp-destination /tmp
92
+ my-local-putio -t 123 -l Downloads -d -s --socks5-proxy 127.0.0.1:3333 --temp-destination /tmp --disk-threshold size 2000
89
93
 
90
- Starting My Local Put.io - version 3.0.0
94
+ Starting My Local Put.io - version 4.3.0
91
95
  https://github.com/rafaelbiriba/my-local-putio
92
96
  =============================================
93
- Full path of the local destination: /Users/user/Downloads
94
- Full path of the temporary destination: /tmp
97
+ Full path of the local destination: /Users/user/Downloads (Free space: 19667 MB)
98
+ Full path of the temporary destination: /tmp (Free space: 8543 MB)
95
99
  >>> Delete remote files enabled!
96
100
  >>> With subtitles enabled!
97
101
  >>> SOCKS5 enabled with 127.0.0.1:3333
102
+ >>> With disk threshold of 2000 MB!
98
103
  =============================================
99
104
  [LOG][2019-07-18 11:11:30] Getting file list for /
100
105
  [LOG][2019-07-18 11:11:31] Getting file list for /ubuntu
@@ -27,6 +27,8 @@ require "my-local-putio/putio_cli"
27
27
  require "my-local-putio/fetcher"
28
28
  require "my-local-putio/downloader"
29
29
  require "my-local-putio/subtitles_manager"
30
+ require "my-local-putio/disk_manager"
31
+
30
32
 
31
33
  module MyLocalPutio
32
34
  def self.print_introduction_msg(configuration)
@@ -34,11 +36,12 @@ module MyLocalPutio
34
36
  puts "Starting My Local Put.io - version #{VERSION}"
35
37
  puts "https://github.com/rafaelbiriba/my-local-putio"
36
38
  puts "============================================="
37
- puts "Full path of the local destination: #{File.realdirpath(configuration.local_destination)}"
38
- puts "Full path of the temporary destination: #{File.realdirpath(configuration.temp_destination)}"
39
+ puts "Full path of the local destination: #{File.realdirpath(configuration.local_destination)} (Free space: #{configuration.disk_manager.get_folder_free_space(configuration.local_destination)} MB)"
40
+ puts "Full path of the temporary destination: #{File.realdirpath(configuration.temp_destination)} (Free space: #{configuration.disk_manager.get_folder_free_space(configuration.temp_destination)} MB)"
39
41
  puts ">>> Delete remote files enabled!" if configuration.delete_remote
40
42
  puts ">>> With subtitles enabled!" if configuration.with_subtitles
41
43
  puts ">>> SOCKS5 enabled with #{configuration.socks_host}:#{configuration.socks_port}" if configuration.socks_enabled?
44
+ puts ">>> With disk threshold of #{configuration.disk_threshold} MB!" if configuration.disk_threshold
42
45
  puts ">>> DEBUG enabled! Hello Mr(s) developer :)" if configuration.debug
43
46
  puts "============================================="
44
47
  sleep 2 # In case the configurations are not correct, 2 seconds to kill the command line before run
@@ -1,7 +1,9 @@
1
1
  module MyLocalPutio
2
2
  class Configuration
3
3
  attr_reader :token, :local_destination, :temp_destination,
4
- :silent, :debug, :socks_host, :socks_port, :delete_remote, :with_subtitles
4
+ :silent, :debug, :socks_host, :socks_port, :delete_remote, :with_subtitles,
5
+ :disk_threshold
6
+
5
7
  def initialize
6
8
  read_args_from_envs!
7
9
  parse_args!
@@ -9,6 +11,10 @@ module MyLocalPutio
9
11
  validate_args!
10
12
  end
11
13
 
14
+ def disk_manager
15
+ @disk_manager ||= DiskManager.new(self)
16
+ end
17
+
12
18
  def socks_enabled?
13
19
  @socks_host || @socks_port
14
20
  end
@@ -35,6 +41,9 @@ module MyLocalPutio
35
41
  opt.on("--socks5-proxy hostname:port", "SOCKS5 hostname and port for proxy. Format: 127.0.0.1:1234") do |v|
36
42
  @socks_host, @socks_port = v.to_s.split(":")
37
43
  end
44
+ opt.on("--disk-threshold size", "Stops the downloads when the disk space threshold is reached. (Size in MB, e.g: 2000 for 2GB)") do |v|
45
+ @disk_threshold = v.to_i
46
+ end
38
47
  end.parse!
39
48
  end
40
49
 
@@ -0,0 +1,26 @@
1
+ module MyLocalPutio
2
+ class DiskManager
3
+ attr_reader :configuration, :logger
4
+
5
+ def initialize(configuration)
6
+ @configuration = configuration
7
+ @logger = configuration.logger
8
+ end
9
+
10
+ def check_for_available_space_on_destinations!(needed_space)
11
+ return unless configuration.disk_threshold
12
+
13
+ [configuration.local_destination, configuration.temp_destination].each do |path|
14
+ free_space = get_folder_free_space(path)
15
+ next unless (free_space - configuration.disk_threshold) <= needed_space
16
+ logger.log "Low disk threshold on path: #{path}! Stopping the script!"
17
+ exit
18
+ end
19
+ end
20
+
21
+ def get_folder_free_space(destination)
22
+ space = `df -Pk #{destination}/ | awk 'NR==2 {print $4}'`.to_i
23
+ (space/1024).to_i.round(2)
24
+ end
25
+ end
26
+ end
@@ -1,10 +1,11 @@
1
1
  module MyLocalPutio
2
2
  class Fetcher
3
- attr_reader :configuration, :cli, :logger, :downloader
3
+ attr_reader :configuration, :cli, :disk_manager, :logger, :downloader
4
4
 
5
5
  def initialize(configuration)
6
6
  @configuration = configuration
7
7
  @logger = configuration.logger
8
+ @disk_manager = configuration.disk_manager
8
9
  @cli = PutioCli.new(@configuration)
9
10
  @downloader = Downloader.new(@configuration)
10
11
  end
@@ -31,6 +32,7 @@ module MyLocalPutio
31
32
  fetch_files(id: file.id, path: local_file_path)
32
33
  else
33
34
  url = cli.get_download_url(file.id)["url"]
35
+ disk_manager.check_for_available_space_on_destinations!(file.size/1024/1024)
34
36
  Downloader.new(@configuration).download(url, local_file_path) unless file_exists?(local_file_path, file)
35
37
  SubtitlesManager.new(configuration).fetch(file, path)
36
38
  end
@@ -1,3 +1,3 @@
1
1
  module MyLocalPutio
2
- VERSION = "4.2.0"
2
+ VERSION = "4.3.0"
3
3
  end
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 2.0"
28
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rake", "~> 13.0"
29
29
  spec.add_dependency "socksify", "1.7.1"
30
30
  end
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: 4.2.0
4
+ version: 4.3.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-08-08 00:00:00.000000000 Z
11
+ date: 2020-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: socksify
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -70,6 +70,7 @@ 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/disk_manager.rb
73
74
  - lib/my-local-putio/downloader.rb
74
75
  - lib/my-local-putio/fetcher.rb
75
76
  - lib/my-local-putio/logger.rb