rmega 0.2.4 → 0.2.5

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
- SHA1:
3
- metadata.gz: c5220ae63878c82e2e72cb324a5277347dfebee7
4
- data.tar.gz: 0055c65dcaca525127fe46a228885eb84100a8c7
2
+ SHA256:
3
+ metadata.gz: 6555304d89d2e8b375962e427881c16873ab8311088dee76e9ad2dd719af7d01
4
+ data.tar.gz: 7808a4295238d240540af37b99f6d05a8f6c05b0ee7a558b9c1ba101836a8a4f
5
5
  SHA512:
6
- metadata.gz: 8051f36840c086b719974538d37b770824663a26ce84177316b0945b9acf6a8ba311668164a0ab23e3b1377a1f18a642b49669d167b43244ac1f7ffde5261ad8
7
- data.tar.gz: eb1cbced4fa134640d631cceca5d03c400bfb1c88499fbc768310f74fbeea09ae416875627fd2e397b9c4025bca17c0f0175646039b842a1a6efe02e4d9b1913
6
+ metadata.gz: 99c86e71c98452e6510a7338dc9ef168f69e27bf239f9149a1cb62af58ff0c1768289354ab6e02bb5e1c71fd92eab3e188a61af0cfe8a4245902b5d9ecf8c047
7
+ data.tar.gz: 389dfb0808a4ccbead5565ddcc46ab0555616b936bd7a2ef3e18d47d8c49d635d4d10f22936a1dbd046d9eb80c97c3dc4f29264e81f25dd385922dd577d3df71
data/.travis.yml CHANGED
@@ -7,4 +7,5 @@ rvm:
7
7
  - 2.1
8
8
  - 2.2
9
9
  - 2.4
10
+ - 2.5
10
11
  - ruby-head
data/bin/rmega-dl CHANGED
@@ -56,7 +56,11 @@ cli_rescue do
56
56
  else
57
57
  # A link to a web page with some MEGA urls in its body
58
58
  html = Rmega::Session.new.http_get_content(cli_options[:url])
59
- urls = html.scan(Rmega::Nodes::Factory::URL_REGEXP).flatten.uniq
59
+ urls = html.scan(Rmega::Nodes::Factory::URL_REGEXP).flatten.select { |u| Rmega::Nodes::Factory.url?(u) }.uniq
60
+
61
+ if cli_options[:debug] and urls.any?
62
+ Rmega.logger.debug("#{urls.size} URL(s) founded:\n" + urls.join("\n"))
63
+ end
60
64
  end
61
65
  end
62
66
 
@@ -64,7 +68,7 @@ cli_rescue do
64
68
 
65
69
  urls.each_with_index do |url, index|
66
70
  node = Rmega::Nodes::Factory.build_from_url(url)
67
- print "[#{index+1}/#{urls.size}] " if urls.size > 1
71
+ puts "[#{index+1}/#{urls.size}] #{url}" if urls.size > 1
68
72
  node.download(cli_options[:output] || Dir.pwd)
69
73
  end
70
74
  end
data/lib/rmega/cli.rb CHANGED
@@ -43,6 +43,10 @@ module Rmega
43
43
  end
44
44
  Rmega.logger.level = ::Logger::DEBUG if cli_options[:debug]
45
45
  Rmega.options.show_progress = true
46
+
47
+ if Thread.respond_to?(:report_on_exception) and !cli_options[:debug]
48
+ Thread.report_on_exception = false
49
+ end
46
50
  end
47
51
 
48
52
  def apply_opt_parser_options(opts)
data/lib/rmega/errors.rb CHANGED
@@ -4,4 +4,14 @@ module Rmega
4
4
 
5
5
  class TemporaryServerError < StandardError
6
6
  end
7
+
8
+ class BandwidthLimitExceeded < StandardError
9
+ def initialize(*args)
10
+ if args.any?
11
+ super
12
+ else
13
+ super("Transfer quota exceeded")
14
+ end
15
+ end
16
+ end
7
17
  end
data/lib/rmega/net.rb CHANGED
@@ -18,7 +18,13 @@ module Rmega
18
18
  def http_get_content(url)
19
19
  uri = URI(url)
20
20
  req = ::Net::HTTP::Get.new(uri.request_uri)
21
- return net_http(uri).request(req).body
21
+ resp = net_http(uri).request(req)
22
+
23
+ if resp.code.to_i == 509 and resp.body.to_s.empty?
24
+ raise BandwidthLimitExceeded.new
25
+ end
26
+
27
+ return resp.body
22
28
  end
23
29
 
24
30
  def http_post(url, data)
@@ -21,7 +21,10 @@ module Rmega
21
21
  FOLDER_URL_REGEXP = /\#\F/
22
22
 
23
23
  def url?(string)
24
- string.to_s =~ URL_REGEXP
24
+ return false unless string.to_s =~ URL_REGEXP
25
+ public_handle, key = string.strip.split('!')[1, 2]
26
+ return false if key and (Utils.base64urldecode(key) rescue nil).nil?
27
+ return true
25
28
  end
26
29
 
27
30
  def build(session, data)
data/lib/rmega/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Rmega
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  HOMEPAGE = "https://github.com/topac/rmega"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmega
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - topac
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-05 00:00:00.000000000 Z
11
+ date: 2019-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.6.12
142
+ rubygems_version: 2.7.6
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: mega.co.nz ruby api