qbt_client 1.0.0 → 2.0.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
  SHA1:
3
- metadata.gz: 8436ebfd25aa67e8c8f10ae8baa2fca78dc29ae2
4
- data.tar.gz: f1877a204e61e20eb554d56feacd60bfcfb5a579
3
+ metadata.gz: 19603f9f387f46f6042de088397e2f79a0fd458c
4
+ data.tar.gz: f5080d278e403119bdccac72968f006da73831b8
5
5
  SHA512:
6
- metadata.gz: ba09cc0d16fcd1d7a8162c8ffeb33d213418e09110bdddf5c8cff49ae8717ced8f1d62325208baf03fa2cccc93f7e4286dcdf6eb471fe9386d37df84f3f8f57d
7
- data.tar.gz: 0df4fa56464b1bf4eff81582e85812519ded024a2ffea0442b4c7f257258f2273b25df90377e5bf8fde981e1c6c2ca497db488295557604b4e908117747d90c4
6
+ metadata.gz: d3366cbdb34f1f6ee4a635a025cfa8d0cc6ec7394c278ad37569645a7296ed06491bdbea3124f7b3d579066d444b25522a3df0aec56e07094e2a6b383b9485b7
7
+ data.tar.gz: f54b45c0fa6e33f3e3b237d4137473931da3925e2c52920e213af0318f710ac7ac35c4b15cfbfec0157f6ddbe8cae517a98d3d00b28b106f6639f9db8b4e5bbb
data/CHANGES.md CHANGED
@@ -9,15 +9,15 @@ Update client to work with qBitTorrent 3.3.4 WebUI changes
9
9
  - `/json/` url paths have changed to `/query/`
10
10
  - `/command/pauseall` has changed to `/command/pauseAll` (all paths are case sensitive)
11
11
  - `/command/resumeall` has changed to `/command/resumeAll`
12
- - `/command/getTorrentDlLimit' changed to `/command/getTorrentsDlLimit`
12
+ - `/command/getTorrentDlLimit` changed to `/command/getTorrentsDlLimit`
13
13
  - `hash` option changed to `hashes` option
14
- - `/command/setTorrentDlLimit' changed to `/command/setTorrentsDlLimit`
14
+ - `/command/setTorrentDlLimit` changed to `/command/setTorrentsDlLimit`
15
15
  - `hash` option changed to `hashes` option
16
- - `/command/getTorrentUpLimit' changed to `/command/getTorrentsUpLimit`
16
+ - `/command/getTorrentUpLimit` changed to `/command/getTorrentsUpLimit`
17
17
  - `hash` option changed to `hashes` option
18
- - `/command/setTorrentUpLimit' changed to `/command/setTorrentsUpLimit`
18
+ - `/command/setTorrentUpLimit` changed to `/command/setTorrentsUpLimit`
19
19
  - `hash` option changed to `hashes` option
20
- - Turn on network debug output when DEBUG env var is set
20
+ - Turn on network debug output when `DEBUG` env var is set
21
21
 
22
22
 
23
23
  ## v0.1.0
data/lib/qbt_client.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "qbt_client/version"
2
2
 
3
3
  module QbtClient
4
+ class QbtClientError < StandardError
5
+ end
4
6
  end
5
7
 
6
8
  require 'qbt_client/web_ui'
@@ -1,3 +1,3 @@
1
1
  module QbtClient
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -32,7 +32,9 @@ module QbtClient
32
32
  @sid = nil
33
33
 
34
34
  #self.class.digest_auth(user, pass)
35
- self.class.base_uri "#{ip}:#{port}"
35
+ host = "#{ip}:#{port}"
36
+ self.class.base_uri host
37
+ self.class.headers "Referer" => host
36
38
  authenticate
37
39
  self.class.cookies.add_cookies(@sid)
38
40
  end
@@ -56,14 +58,46 @@ module QbtClient
56
58
  res = self.class.post('/login', options)
57
59
  if res.success?
58
60
  token = res.headers["Set-Cookie"]
59
- raise "Login failed" if token.nil?
61
+ raise QbtClientError.new("Login failed: no SID (cookie) returned") if token.nil?
60
62
 
61
63
  token = token.split(";")[0]
62
- #token = token.split("SID=")[1]
63
64
  @sid = token
65
+ else
66
+ raise QbtClientError.new(res)
64
67
  end
65
68
  end
66
69
 
70
+ ###
71
+ # Get the application's API version
72
+ #
73
+ # Returns an integer
74
+ #
75
+ def api_version
76
+ self.class.format :json
77
+ self.class.get('/version/api').parsed_response
78
+ end
79
+
80
+ ###
81
+ # Get the application's minimum API version
82
+ #
83
+ # Returns an integer
84
+ #
85
+ def api_min_version
86
+ self.class.format :json
87
+ self.class.get('/version/api_min').parsed_response
88
+ end
89
+
90
+ ###
91
+ # Get the application's version
92
+ #
93
+ # Returns an integer
94
+ #
95
+ def qbittorrent_version
96
+ self.class.format :plain
97
+ self.class.get('/version/qbittorrent').parsed_response
98
+ #self.class.get('/version/qbittorrent')
99
+ end
100
+
67
101
  ###
68
102
  # Get array of all torrents
69
103
  #
data/qbt_client.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency "httparty", "~> 0.7"
22
+ spec.add_runtime_dependency "json"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.7"
24
25
  spec.add_development_dependency "rake", "~> 10.0"
@@ -8,6 +8,42 @@ describe WebUI do
8
8
  sleep 1
9
9
  end
10
10
 
11
+ context "#api_version" do
12
+
13
+ it "return the current API version" do
14
+ hash, name = given_a_paused_downloading_torrent
15
+ client = WebUI.new(test_ip, test_port, test_user, test_pass)
16
+ api_ver = client.api_version
17
+
18
+ puts " api version: #{api_ver}"
19
+ expect(api_ver.integer?).to eq true
20
+ end
21
+ end
22
+
23
+ context "#api_min_version" do
24
+
25
+ it "return the minimum API version" do
26
+ hash, name = given_a_paused_downloading_torrent
27
+ client = WebUI.new(test_ip, test_port, test_user, test_pass)
28
+ api_ver = client.api_min_version
29
+
30
+ puts " minimum api version: #{api_ver}"
31
+ expect(api_ver.integer?).to eq true
32
+ end
33
+ end
34
+
35
+ context "#qbittorrent_version" do
36
+
37
+ it "return the application version" do
38
+ hash, name = given_a_paused_downloading_torrent
39
+ client = WebUI.new(test_ip, test_port, test_user, test_pass)
40
+ app_ver = client.qbittorrent_version
41
+
42
+ puts " qbittorrent version: #{app_ver}"
43
+ expect(app_ver.start_with?('v')).to eq true
44
+ end
45
+ end
46
+
11
47
  context "#torrent_list" do
12
48
 
13
49
  it "returns array of torrents" do
@@ -185,7 +221,9 @@ describe WebUI do
185
221
 
186
222
  # Read preferences back and verify update
187
223
  res = client.preferences
188
- expect(res["save_path"]).to eq save_path
224
+ # NOTE: qBitTorrent now tacks on a trailing file separator to its
225
+ # save path if it doesn't already exist.
226
+ expect(res["save_path"]).to eq (save_path + "/")
189
227
 
190
228
  # Set the save_path back to original value
191
229
  res = client.set_preferences({ "save_path"=>orig_save_path })
@@ -221,7 +259,7 @@ describe WebUI do
221
259
  client = WebUI.new(test_ip, test_port, test_user, test_pass)
222
260
  res = client.pause_all
223
261
  # Give app a chance to update
224
- sleep 2
262
+ sleep 4
225
263
 
226
264
  data = client.torrent_data hash
227
265
  #print_response data
@@ -531,6 +569,10 @@ describe WebUI do
531
569
 
532
570
  actual_limit = client.global_download_limit
533
571
 
572
+ puts " old limit: #{old_limit}"
573
+ puts " expected limit: #{expected_limit}"
574
+ puts " actual limit: #{actual_limit}"
575
+
534
576
  expect(expected_limit == actual_limit).to eq true
535
577
 
536
578
  # Clean up
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qbt_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff McAffee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-03 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
150
  version: '0'
137
151
  requirements: []
138
152
  rubyforge_project:
139
- rubygems_version: 2.4.5.1
153
+ rubygems_version: 2.5.1
140
154
  signing_key:
141
155
  specification_version: 4
142
156
  summary: qBittorent client