qbt_client 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGES.md +25 -0
- data/README.md +2 -2
- data/lib/qbt_client/version.rb +1 -1
- data/lib/qbt_client/web_ui.rb +54 -18
- data/spec/lib/qbt_client/web_ui_spec.rb +18 -7
- data/spec/lib/qbt_client_spec.rb +0 -4
- data/spec/spec_helper.rb +6 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8436ebfd25aa67e8c8f10ae8baa2fca78dc29ae2
|
4
|
+
data.tar.gz: f1877a204e61e20eb554d56feacd60bfcfb5a579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba09cc0d16fcd1d7a8162c8ffeb33d213418e09110bdddf5c8cff49ae8717ced8f1d62325208baf03fa2cccc93f7e4286dcdf6eb471fe9386d37df84f3f8f57d
|
7
|
+
data.tar.gz: 0df4fa56464b1bf4eff81582e85812519ded024a2ffea0442b4c7f257258f2273b25df90377e5bf8fde981e1c6c2ca497db488295557604b4e908117747d90c4
|
data/.gitignore
CHANGED
data/CHANGES.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# qbt_client CHANGELOG
|
2
|
+
|
3
|
+
## v1.0.0
|
4
|
+
|
5
|
+
Update client to work with qBitTorrent 3.3.4 WebUI changes
|
6
|
+
|
7
|
+
- Login method has changed from digest authentication to cookie based token
|
8
|
+
- NOTE: minimum password length is now 6 chars
|
9
|
+
- `/json/` url paths have changed to `/query/`
|
10
|
+
- `/command/pauseall` has changed to `/command/pauseAll` (all paths are case sensitive)
|
11
|
+
- `/command/resumeall` has changed to `/command/resumeAll`
|
12
|
+
- `/command/getTorrentDlLimit' changed to `/command/getTorrentsDlLimit`
|
13
|
+
- `hash` option changed to `hashes` option
|
14
|
+
- `/command/setTorrentDlLimit' changed to `/command/setTorrentsDlLimit`
|
15
|
+
- `hash` option changed to `hashes` option
|
16
|
+
- `/command/getTorrentUpLimit' changed to `/command/getTorrentsUpLimit`
|
17
|
+
- `hash` option changed to `hashes` option
|
18
|
+
- `/command/setTorrentUpLimit' changed to `/command/setTorrentsUpLimit`
|
19
|
+
- `hash` option changed to `hashes` option
|
20
|
+
- Turn on network debug output when DEBUG env var is set
|
21
|
+
|
22
|
+
|
23
|
+
## v0.1.0
|
24
|
+
|
25
|
+
Initial release
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ require 'qtb_client'
|
|
28
28
|
ip = 'http://127.0.0.1' # Protocol is required.
|
29
29
|
port = 8083
|
30
30
|
user = 'admin'
|
31
|
-
pass = '
|
31
|
+
pass = 'abcabc' # Min length for password is 6 chars
|
32
32
|
|
33
33
|
client = QtbClient::WebUI.new(ip, port, user, pass)
|
34
34
|
```
|
@@ -59,7 +59,7 @@ To run the tests, you'll need to have qBittorrent installed locally, WebUI
|
|
59
59
|
turned on, and the credentials set to:
|
60
60
|
|
61
61
|
- user: admin
|
62
|
-
- pass:
|
62
|
+
- pass: abcabc
|
63
63
|
|
64
64
|
The tests assume that qBittorrent is running at 127.0.0.1, port 8083.
|
65
65
|
|
data/lib/qbt_client/version.rb
CHANGED
data/lib/qbt_client/web_ui.rb
CHANGED
@@ -17,7 +17,9 @@ module QbtClient
|
|
17
17
|
class WebUI
|
18
18
|
include HTTParty
|
19
19
|
|
20
|
-
|
20
|
+
if ENV["DEBUG"]
|
21
|
+
debug_output $stdout
|
22
|
+
end
|
21
23
|
|
22
24
|
###
|
23
25
|
# constructor
|
@@ -27,9 +29,39 @@ module QbtClient
|
|
27
29
|
@port = port
|
28
30
|
@user = user
|
29
31
|
@pass = pass
|
32
|
+
@sid = nil
|
30
33
|
|
31
|
-
self.class.digest_auth(user, pass)
|
34
|
+
#self.class.digest_auth(user, pass)
|
32
35
|
self.class.base_uri "#{ip}:#{port}"
|
36
|
+
authenticate
|
37
|
+
self.class.cookies.add_cookies(@sid)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
###
|
42
|
+
# Authenticate with the server
|
43
|
+
#
|
44
|
+
# Login with username and password.
|
45
|
+
# Store returned SID cookie value used as auth token for later calls.
|
46
|
+
#
|
47
|
+
def authenticate
|
48
|
+
options = {
|
49
|
+
body: "username=#{@user}&password=#{@pass}"
|
50
|
+
}
|
51
|
+
|
52
|
+
# Have to clear out the cookies or the old SID gets sent while requesting
|
53
|
+
# the new SID (and it fails).
|
54
|
+
self.class.cookies.clear
|
55
|
+
|
56
|
+
res = self.class.post('/login', options)
|
57
|
+
if res.success?
|
58
|
+
token = res.headers["Set-Cookie"]
|
59
|
+
raise "Login failed" if token.nil?
|
60
|
+
|
61
|
+
token = token.split(";")[0]
|
62
|
+
#token = token.split("SID=")[1]
|
63
|
+
@sid = token
|
64
|
+
end
|
33
65
|
end
|
34
66
|
|
35
67
|
###
|
@@ -69,7 +101,7 @@ module QbtClient
|
|
69
101
|
#
|
70
102
|
def torrent_list
|
71
103
|
self.class.format :json
|
72
|
-
self.class.get('/
|
104
|
+
self.class.get('/query/torrents').parsed_response
|
73
105
|
end
|
74
106
|
|
75
107
|
def torrent_data torrent_hash
|
@@ -104,7 +136,7 @@ module QbtClient
|
|
104
136
|
#
|
105
137
|
def properties torrent_hash
|
106
138
|
self.class.format :json
|
107
|
-
self.class.get('/
|
139
|
+
self.class.get('/query/propertiesGeneral/' + torrent_hash).parsed_response
|
108
140
|
end
|
109
141
|
|
110
142
|
###
|
@@ -136,7 +168,7 @@ module QbtClient
|
|
136
168
|
#
|
137
169
|
def trackers torrent_hash
|
138
170
|
self.class.format :json
|
139
|
-
self.class.get('/
|
171
|
+
self.class.get('/query/propertiesTrackers/' + torrent_hash).parsed_response
|
140
172
|
end
|
141
173
|
|
142
174
|
###
|
@@ -173,7 +205,7 @@ module QbtClient
|
|
173
205
|
#
|
174
206
|
def contents torrent_hash
|
175
207
|
self.class.format :json
|
176
|
-
self.class.get('/
|
208
|
+
self.class.get('/query/propertiesFiles/' + torrent_hash).parsed_response
|
177
209
|
end
|
178
210
|
|
179
211
|
###
|
@@ -187,7 +219,7 @@ module QbtClient
|
|
187
219
|
#
|
188
220
|
def transfer_info
|
189
221
|
self.class.format :json
|
190
|
-
self.class.get('/
|
222
|
+
self.class.get('/query/transferInfo').parsed_response
|
191
223
|
end
|
192
224
|
|
193
225
|
###
|
@@ -269,7 +301,7 @@ module QbtClient
|
|
269
301
|
#
|
270
302
|
def preferences
|
271
303
|
self.class.format :json
|
272
|
-
self.class.get('/
|
304
|
+
self.class.get('/query/preferences').parsed_response
|
273
305
|
end
|
274
306
|
|
275
307
|
###
|
@@ -303,7 +335,7 @@ module QbtClient
|
|
303
335
|
# Pause all torrents
|
304
336
|
#
|
305
337
|
def pause_all
|
306
|
-
self.class.post('/command/
|
338
|
+
self.class.post('/command/pauseAll')
|
307
339
|
end
|
308
340
|
|
309
341
|
###
|
@@ -321,7 +353,7 @@ module QbtClient
|
|
321
353
|
# Resume downloading/seeding of all torrents
|
322
354
|
#
|
323
355
|
def resume_all
|
324
|
-
self.class.post('/command/
|
356
|
+
self.class.post('/command/resumeAll')
|
325
357
|
end
|
326
358
|
|
327
359
|
###
|
@@ -539,10 +571,12 @@ module QbtClient
|
|
539
571
|
self.class.format :json
|
540
572
|
|
541
573
|
options = {
|
542
|
-
body: "
|
574
|
+
body: "hashes=#{torrent_hash}"
|
543
575
|
}
|
544
576
|
|
545
|
-
self.class
|
577
|
+
self.class
|
578
|
+
.post('/command/getTorrentsDlLimit', options)
|
579
|
+
.parsed_response[torrent_hash]
|
546
580
|
end
|
547
581
|
|
548
582
|
###
|
@@ -554,13 +588,13 @@ module QbtClient
|
|
554
588
|
# limit: integer (bytes)
|
555
589
|
#
|
556
590
|
def set_download_limit torrent_hash, limit
|
557
|
-
query = ["
|
591
|
+
query = ["hashes=#{torrent_hash}", "limit=#{limit}"]
|
558
592
|
|
559
593
|
options = {
|
560
594
|
body: query.join('&')
|
561
595
|
}
|
562
596
|
|
563
|
-
self.class.post('/command/
|
597
|
+
self.class.post('/command/setTorrentsDlLimit', options)
|
564
598
|
end
|
565
599
|
|
566
600
|
###
|
@@ -574,10 +608,12 @@ module QbtClient
|
|
574
608
|
self.class.format :json
|
575
609
|
|
576
610
|
options = {
|
577
|
-
body: "
|
611
|
+
body: "hashes=#{torrent_hash}"
|
578
612
|
}
|
579
613
|
|
580
|
-
self.class
|
614
|
+
self.class
|
615
|
+
.post('/command/getTorrentsUpLimit', options)
|
616
|
+
.parsed_response[torrent_hash]
|
581
617
|
end
|
582
618
|
|
583
619
|
###
|
@@ -589,13 +625,13 @@ module QbtClient
|
|
589
625
|
# limit: integer (bytes)
|
590
626
|
#
|
591
627
|
def set_upload_limit torrent_hash, limit
|
592
|
-
query = ["
|
628
|
+
query = ["hashes=#{torrent_hash}", "limit=#{limit}"]
|
593
629
|
|
594
630
|
options = {
|
595
631
|
body: query.join('&')
|
596
632
|
}
|
597
633
|
|
598
|
-
self.class.post('/command/
|
634
|
+
self.class.post('/command/setTorrentsUpLimit', options)
|
599
635
|
end
|
600
636
|
|
601
637
|
private
|
@@ -153,8 +153,8 @@ describe WebUI do
|
|
153
153
|
res = client.transfer_info
|
154
154
|
|
155
155
|
expect(res.class).to eq Hash
|
156
|
-
expect(res['
|
157
|
-
expect(res['
|
156
|
+
expect(res['dl_info_data']).to_not eq nil
|
157
|
+
expect(res['up_info_data']).to_not eq nil
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
@@ -193,7 +193,7 @@ describe WebUI do
|
|
193
193
|
|
194
194
|
it "fails when not provided a Hash" do
|
195
195
|
client = WebUI.new(test_ip, test_port, test_user, test_pass)
|
196
|
-
expect{ client.set_preferences("\"save_path\":\"#{save_path}\"") }.to raise_exception
|
196
|
+
expect{ client.set_preferences("\"save_path\":\"#{save_path}\"") }.to raise_exception( TypeError )
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
@@ -356,6 +356,8 @@ describe WebUI do
|
|
356
356
|
#puts "State: #{data['state']}"
|
357
357
|
state_is_expected = (state == 'checkingDL' or state == 'checkingUP')
|
358
358
|
|
359
|
+
puts " expected state: checkingDL or checkingUP"
|
360
|
+
puts " actual state: #{state}"
|
359
361
|
expect(state_is_expected).to eq true
|
360
362
|
end
|
361
363
|
end
|
@@ -371,13 +373,14 @@ describe WebUI do
|
|
371
373
|
# Turn on queueing or priority is always '*'.
|
372
374
|
enable_queueing client, true
|
373
375
|
sleep 2
|
376
|
+
puts " queuing enabled: #{queueing_enabled?(client)}"
|
374
377
|
|
375
378
|
# Get initial priority.
|
376
379
|
prio = get_torrent_info client, hash2, 'priority'
|
377
380
|
|
378
381
|
# Increase the priority.
|
379
382
|
client.increase_priority hash2
|
380
|
-
sleep
|
383
|
+
sleep 5
|
381
384
|
|
382
385
|
# Verify it got better (lower number).
|
383
386
|
prio_after_increase = get_torrent_info client, hash2, 'priority'
|
@@ -400,13 +403,14 @@ describe WebUI do
|
|
400
403
|
# Turn on queueing or priority is always '*'.
|
401
404
|
enable_queueing client, true
|
402
405
|
sleep 2
|
406
|
+
puts " queuing enabled: #{queueing_enabled?(client)}"
|
403
407
|
|
404
408
|
# Get initial priority.
|
405
409
|
prio = get_torrent_info client, hash, 'priority'
|
406
410
|
|
407
411
|
# Decrease the priority.
|
408
412
|
client.decrease_priority hash
|
409
|
-
sleep
|
413
|
+
sleep 5
|
410
414
|
|
411
415
|
# Verify it got worse (higher number).
|
412
416
|
prio_after_decrease = get_torrent_info client, hash, 'priority'
|
@@ -443,7 +447,8 @@ describe WebUI do
|
|
443
447
|
# Turn queueing back off.
|
444
448
|
enable_queueing client, false
|
445
449
|
|
446
|
-
|
450
|
+
puts " prio_after_increase: #{prio_after_increase}"
|
451
|
+
expect(prio_after_increase == 1).to eq true
|
447
452
|
end
|
448
453
|
end
|
449
454
|
|
@@ -472,7 +477,8 @@ describe WebUI do
|
|
472
477
|
# Turn queueing back off.
|
473
478
|
enable_queueing client, false
|
474
479
|
|
475
|
-
|
480
|
+
puts " prio_after_decrease: #{prio_after_decrease}"
|
481
|
+
expect(prio_after_decrease == 2).to eq true
|
476
482
|
end
|
477
483
|
end
|
478
484
|
|
@@ -569,6 +575,8 @@ describe WebUI do
|
|
569
575
|
client = WebUI.new(test_ip, test_port, test_user, test_pass)
|
570
576
|
limit = client.download_limit hash
|
571
577
|
|
578
|
+
puts " limit is #{limit}"
|
579
|
+
|
572
580
|
expect(limit.integer?).to eq true
|
573
581
|
end
|
574
582
|
end
|
@@ -585,6 +593,9 @@ describe WebUI do
|
|
585
593
|
|
586
594
|
actual_limit = client.download_limit hash
|
587
595
|
|
596
|
+
puts " expected limit is #{expected_limit}"
|
597
|
+
puts " actual limit is #{actual_limit}"
|
598
|
+
|
588
599
|
expect(expected_limit == actual_limit).to eq true
|
589
600
|
|
590
601
|
# Clean up
|
data/spec/lib/qbt_client_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -20,7 +20,7 @@ def test_user
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_pass
|
23
|
-
'
|
23
|
+
'abcabc'
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_torrent_url
|
@@ -149,6 +149,11 @@ def enable_queueing client, enable
|
|
149
149
|
client.set_preferences({ "queueing_enabled" => enable })
|
150
150
|
end
|
151
151
|
|
152
|
+
def queueing_enabled? client
|
153
|
+
prefs = client.preferences
|
154
|
+
prefs['queueing_enabled']
|
155
|
+
end
|
156
|
+
|
152
157
|
def delete_all_torrents
|
153
158
|
client = QbtClient::WebUI.new(test_ip, test_port, test_user, test_pass)
|
154
159
|
torrents = client.torrent_list
|
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:
|
4
|
+
version: 1.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:
|
11
|
+
date: 2016-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- ".gitignore"
|
105
105
|
- ".rspec"
|
106
106
|
- ".travis.yml"
|
107
|
+
- CHANGES.md
|
107
108
|
- Gemfile
|
108
109
|
- LICENSE.txt
|
109
110
|
- README.md
|
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
138
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.4.5.1
|
139
140
|
signing_key:
|
140
141
|
specification_version: 4
|
141
142
|
summary: qBittorent client
|
@@ -143,4 +144,3 @@ test_files:
|
|
143
144
|
- spec/lib/qbt_client/web_ui_spec.rb
|
144
145
|
- spec/lib/qbt_client_spec.rb
|
145
146
|
- spec/spec_helper.rb
|
146
|
-
has_rdoc:
|