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 +5 -5
- data/.travis.yml +1 -0
- data/bin/rmega-dl +6 -2
- data/lib/rmega/cli.rb +4 -0
- data/lib/rmega/errors.rb +10 -0
- data/lib/rmega/net.rb +7 -1
- data/lib/rmega/nodes/factory.rb +4 -1
- data/lib/rmega/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6555304d89d2e8b375962e427881c16873ab8311088dee76e9ad2dd719af7d01
|
4
|
+
data.tar.gz: 7808a4295238d240540af37b99f6d05a8f6c05b0ee7a558b9c1ba101836a8a4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99c86e71c98452e6510a7338dc9ef168f69e27bf239f9149a1cb62af58ff0c1768289354ab6e02bb5e1c71fd92eab3e188a61af0cfe8a4245902b5d9ecf8c047
|
7
|
+
data.tar.gz: 389dfb0808a4ccbead5565ddcc46ab0555616b936bd7a2ef3e18d47d8c49d635d4d10f22936a1dbd046d9eb80c97c3dc4f29264e81f25dd385922dd577d3df71
|
data/.travis.yml
CHANGED
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
|
-
|
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
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
|
-
|
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)
|
data/lib/rmega/nodes/factory.rb
CHANGED
@@ -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
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
|
+
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:
|
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
|
142
|
+
rubygems_version: 2.7.6
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: mega.co.nz ruby api
|