qnap-download_station 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -6
- data/lib/qnap/download_station.rb +11 -3
- data/qnap-download_station.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b10081f0cf4abe429c48bdd7c60fa15d34c4fda8
|
4
|
+
data.tar.gz: 6104a3b1f6dc9db6d4d8d022aa1de0307a59f503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9961e935e456e2c7c3fdc568dca3c8db08066df54ab1bee6c67be8a7bae17c5b8d50b64b10d78412e0a4fb7cac6ae7dc04c51e7347ba12a457cfac879e0ac5b
|
7
|
+
data.tar.gz: f27c1be4a506a4e0286832c64cbba2d7b21c51b450ebdd50bd0cb0b2611668c5eb416b79a118016a79b87b0d19cc1714c0367a7a6cf08d1fdde4ea822543816e
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Qnap::DownloadStation
|
2
2
|
=======
|
3
3
|
|
4
|
-
This gem provides an interface to the Download Station app that comes installed by default on many QNAP NAS
|
4
|
+
This gem provides an interface to the Download Station app that comes installed by default on many QNAP NAS.
|
5
5
|
|
6
|
-
It
|
6
|
+
It provides access to all available endpoints, but only a few have been documented.
|
7
7
|
|
8
8
|
Installation
|
9
9
|
-------
|
@@ -24,6 +24,17 @@ active_downloads = ds.task_query
|
|
24
24
|
ds.logout
|
25
25
|
```
|
26
26
|
|
27
|
+
```ruby
|
28
|
+
# Alternative syntax to guarantee logout
|
29
|
+
|
30
|
+
Qnap::DownloadStation.session('192.168.1.100', 'username', 'password') do |ds|
|
31
|
+
ds.task_add_url temp: 'Download', move: 'Multimedia/New', url: magnet_link
|
32
|
+
pp ds.task_query
|
33
|
+
# logout is automatically called, even if there was an exception
|
34
|
+
end
|
35
|
+
|
36
|
+
```
|
37
|
+
|
27
38
|
Available methods
|
28
39
|
-------
|
29
40
|
|
@@ -52,7 +63,7 @@ Available methods
|
|
52
63
|
* misc_logout
|
53
64
|
* misc_socks_5
|
54
65
|
|
55
|
-
**
|
66
|
+
**RSS methods**
|
56
67
|
* rss_add
|
57
68
|
* rss_add_job
|
58
69
|
* rss_query
|
@@ -78,8 +89,9 @@ Available methods
|
|
78
89
|
* task_status
|
79
90
|
* task_stop
|
80
91
|
|
81
|
-
|
92
|
+
TODO
|
82
93
|
-------
|
83
94
|
|
84
|
-
*
|
85
|
-
*
|
95
|
+
* Document the endpoints
|
96
|
+
* Input validation
|
97
|
+
* Allow users to specify a SSL cert instead of just ignoring certificate errors
|
@@ -17,6 +17,15 @@ module Qnap
|
|
17
17
|
addon: [:query, :enable, :verify, :install, :uninstall, :search],
|
18
18
|
}
|
19
19
|
|
20
|
+
def self.session(*args)
|
21
|
+
ds = self.new *args
|
22
|
+
begin
|
23
|
+
yield ds
|
24
|
+
ensure
|
25
|
+
ds.logout
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
20
29
|
def logout
|
21
30
|
return unless @sid
|
22
31
|
|
@@ -62,7 +71,7 @@ module Qnap
|
|
62
71
|
|
63
72
|
def uri_for_path(app, endpoint)
|
64
73
|
path = [app, endpoint].map { |s| s.to_s.gsub(/(^|_)(.)/){ $2.upcase } }.join "/"
|
65
|
-
URI
|
74
|
+
URI "#{PROTOCOL}://#{@host}/#{APP_NAME}/#{API_VERSION}/#{path}"
|
66
75
|
end
|
67
76
|
|
68
77
|
def despatch_query(uri, params)
|
@@ -81,8 +90,7 @@ module Qnap
|
|
81
90
|
data = JSON.parse response.read_body, symbolize_names: true
|
82
91
|
|
83
92
|
if (data.key?(:error) and data[:error] > 0)
|
84
|
-
|
85
|
-
raise RuntimeError.new data[:reason]
|
93
|
+
raise RuntimeError.new "Error response from #{uri} -> #{data}"
|
86
94
|
end
|
87
95
|
|
88
96
|
data
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qnap-download_station
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cyclotron3k
|
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
43
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.
|
44
|
+
rubygems_version: 2.2.2
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: Interface to the Download Station API
|