transmission-rpc-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +37 -0
- data/LICENSE +19 -0
- data/README.md +78 -0
- data/Rakefile +3 -0
- data/lib/transmission.rb +8 -0
- data/lib/transmission/arguments.rb +27 -0
- data/lib/transmission/arguments/session_get.rb +63 -0
- data/lib/transmission/arguments/session_set.rb +58 -0
- data/lib/transmission/arguments/session_stats.rb +17 -0
- data/lib/transmission/arguments/torrent_add.rb +22 -0
- data/lib/transmission/arguments/torrent_get.rb +78 -0
- data/lib/transmission/arguments/torrent_set.rb +34 -0
- data/lib/transmission/config.rb +18 -0
- data/lib/transmission/model.rb +8 -0
- data/lib/transmission/model/session.rb +35 -0
- data/lib/transmission/model/torrent.rb +97 -0
- data/lib/transmission/rpc.rb +108 -0
- data/lib/transmission/rpc/connector.rb +69 -0
- data/spec/helpers/stubs.rb +60 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/transmission/arguments_spec.rb +34 -0
- data/spec/transmission/model/torrent_spec.rb +146 -0
- data/spec/transmission/rpc/connector_spec.rb +81 -0
- data/spec/transmission/rpc_spec.rb +41 -0
- data/transmission-rpc-ruby.gemspec +17 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4917b1b8a5ad7da8273c58280fac4f25996e6334
|
4
|
+
data.tar.gz: fb8415abcd21be4158c10195b2d2a2fa0ae9dc6e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 65366f6cafbce62cd391596bcec5c5455adf8e2edb6730e92031b74e11f9c10c1984c8f258906d9c592b04433c0fde71d34e28615d56ae932cdfa43426dd5d89
|
7
|
+
data.tar.gz: 70fd3fcfe593fa9c9ae34b07fe3be75a292fd596f64f957dc036b1306fbc6b94b1cd4091242a9b53be6e0a0a4927f6abb8b9ee2b2236dd3b29ffca6340a0dade
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.3.7)
|
5
|
+
crack (0.4.2)
|
6
|
+
safe_yaml (~> 1.0.0)
|
7
|
+
diff-lcs (1.2.5)
|
8
|
+
faraday (0.9.1)
|
9
|
+
multipart-post (>= 1.2, < 3)
|
10
|
+
multipart-post (2.0.0)
|
11
|
+
rake (10.4.2)
|
12
|
+
rspec (3.2.0)
|
13
|
+
rspec-core (~> 3.2.0)
|
14
|
+
rspec-expectations (~> 3.2.0)
|
15
|
+
rspec-mocks (~> 3.2.0)
|
16
|
+
rspec-core (3.2.1)
|
17
|
+
rspec-support (~> 3.2.0)
|
18
|
+
rspec-expectations (3.2.0)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.2.0)
|
21
|
+
rspec-mocks (3.2.1)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.2.0)
|
24
|
+
rspec-support (3.2.2)
|
25
|
+
safe_yaml (1.0.4)
|
26
|
+
webmock (1.20.4)
|
27
|
+
addressable (>= 2.3.6)
|
28
|
+
crack (>= 0.3.2)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
faraday (~> 0.9)
|
35
|
+
rake (~> 10.4)
|
36
|
+
rspec (~> 3.2)
|
37
|
+
webmock (~> 1.20)
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2015 Max Hoffmann
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Transmission RPC Ruby
|
2
|
+
|
3
|
+
First primitive version.
|
4
|
+
|
5
|
+
There is a couple of these RPC wrappers around already, but I am looking for a nice object oriented solution.
|
6
|
+
|
7
|
+
Main aim for this project => Object Oriented solution for Transmission RPC connection.
|
8
|
+
|
9
|
+
This Project follows the RPC spec for transmission under `https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt` and is planning on supporting release version >= 2.40 and RPC version >= 14
|
10
|
+
|
11
|
+
## Examples (Currently working)
|
12
|
+
|
13
|
+
To use the `Model` classes you need to set up some configs first
|
14
|
+
|
15
|
+
Transmission::Config.set host: 'some.host', port: 9091, ssl: false, credentials: {username: 'transmission', password: '********'}
|
16
|
+
|
17
|
+
Now all models will use the globally set configs
|
18
|
+
|
19
|
+
### Finding a torrent
|
20
|
+
|
21
|
+
torrent = Transmission::Model::Torrent.find 1
|
22
|
+
|
23
|
+
### Getting all torrents
|
24
|
+
|
25
|
+
torrents = Transmission::Model::Torrent.all
|
26
|
+
|
27
|
+
### Adding a torrent
|
28
|
+
|
29
|
+
torrent = Transmission::Model::Torrent.add filename: 'http://example.com/some_torrent.torrent'
|
30
|
+
# or
|
31
|
+
torrent = Transmission::Model::Torrent.add filename: 'magnet_link'
|
32
|
+
|
33
|
+
### Deleting a torrent
|
34
|
+
|
35
|
+
torrent = Transmission::Model::Torrent.find 1
|
36
|
+
# Deletes torrents
|
37
|
+
torrent.delete!
|
38
|
+
# Deletes torrent and local data
|
39
|
+
torrent.delete! true
|
40
|
+
|
41
|
+
### Dealing with fields
|
42
|
+
|
43
|
+
To limit the amount of fields sent around you can limit the information by passing an array of desired fields
|
44
|
+
|
45
|
+
torrent = Transmission::Model::Torrent.all fields: ['id']
|
46
|
+
|
47
|
+
### Using different connectors
|
48
|
+
|
49
|
+
If you are planning on using this lib to connect to multiple transmission daemon instances you can pass your own `Transmission::RPC` instance
|
50
|
+
|
51
|
+
connector = Transmission::RPC.new host: 'some.host', port: 9091, ssl: false, credentials: {username: 'transmission', password: '********'}
|
52
|
+
torrents = Transmission::Model::Torrent.all connector: connector
|
53
|
+
|
54
|
+
### Find out Transmission & RPC version
|
55
|
+
|
56
|
+
connector = Transmission::RPC.new host: 'some.host', port: 9091, ssl: false, credentials: {username: 'transmission', password: '********'}
|
57
|
+
session = connector.session
|
58
|
+
session.rpc_version #=> 14
|
59
|
+
session.version #=> "2.52"
|
60
|
+
|
61
|
+
## Examples (Currently NOT working but desired)
|
62
|
+
|
63
|
+
### Torrent instance methods
|
64
|
+
|
65
|
+
torrent = Transmission::Model::Torrent.find 1
|
66
|
+
torrent.move_up
|
67
|
+
torrent.move_down
|
68
|
+
torrent.move_top
|
69
|
+
torrent.move_bottom
|
70
|
+
torrent.start
|
71
|
+
torrent.start_now
|
72
|
+
torrent.stop
|
73
|
+
torrent.verify
|
74
|
+
torrent.re_announce
|
75
|
+
torrent.finished?
|
76
|
+
torrent.to_json
|
77
|
+
|
78
|
+
### This project is still WIP!!
|
data/Rakefile
ADDED
data/lib/transmission.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'transmission', 'rpc')
|
2
|
+
require File.join(File.dirname(__FILE__), 'transmission', 'model')
|
3
|
+
require File.join(File.dirname(__FILE__), 'transmission', 'config')
|
4
|
+
require File.join(File.dirname(__FILE__), 'transmission', 'arguments')
|
5
|
+
|
6
|
+
module Transmission
|
7
|
+
VERSION = '0.1.0'
|
8
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'arguments', 'torrent_add')
|
2
|
+
require File.join(File.dirname(__FILE__), 'arguments', 'torrent_get')
|
3
|
+
require File.join(File.dirname(__FILE__), 'arguments', 'torrent_set')
|
4
|
+
require File.join(File.dirname(__FILE__), 'arguments', 'session_get')
|
5
|
+
require File.join(File.dirname(__FILE__), 'arguments', 'session_set')
|
6
|
+
require File.join(File.dirname(__FILE__), 'arguments', 'session_stats')
|
7
|
+
|
8
|
+
module Transmission
|
9
|
+
class Arguments
|
10
|
+
class InvalidArgument < StandardError; end
|
11
|
+
|
12
|
+
attr_accessor :arguments
|
13
|
+
|
14
|
+
def initialize(arguments = nil)
|
15
|
+
@arguments = arguments.inject([]) do |attributes, attribute|
|
16
|
+
raise Transmission::Arguments::InvalidArgument unless self.class::ATTRIBUTES.include? attribute
|
17
|
+
attributes << attribute
|
18
|
+
end if arguments
|
19
|
+
@arguments = self.class::ATTRIBUTES if arguments.nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_arguments
|
23
|
+
@arguments
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Transmission
|
2
|
+
class Arguments
|
3
|
+
class SessionGet < Transmission::Arguments
|
4
|
+
|
5
|
+
ATTRIBUTES = [
|
6
|
+
'alt-speed-down',
|
7
|
+
'alt-speed-enabled',
|
8
|
+
'alt-speed-time-begin',
|
9
|
+
'alt-speed-time-enabled',
|
10
|
+
'alt-speed-time-end',
|
11
|
+
'alt-speed-time-day',
|
12
|
+
'alt-speed-up',
|
13
|
+
'blocklist-url',
|
14
|
+
'blocklist-update',
|
15
|
+
'blocklist-enabled',
|
16
|
+
'blocklist-size',
|
17
|
+
'cache-size-mb',
|
18
|
+
'config-dir',
|
19
|
+
'download-dir',
|
20
|
+
'download-queue-size',
|
21
|
+
'download-queue-enabled',
|
22
|
+
'dht-enabled',
|
23
|
+
'encryption',
|
24
|
+
'required',
|
25
|
+
'preferred',
|
26
|
+
'tolerated',
|
27
|
+
'idle-seeding-limit',
|
28
|
+
'idle-seeding-limit-enabled',
|
29
|
+
'incomplete-dir',
|
30
|
+
'incomplete-dir-enabled',
|
31
|
+
'lpd-enabled',
|
32
|
+
'peer-limit-global',
|
33
|
+
'peer-limit-per-torrent',
|
34
|
+
'pex-enabled',
|
35
|
+
'peer-port',
|
36
|
+
'peer-port-random-on-start',
|
37
|
+
'port-forwarding-enabled',
|
38
|
+
'queue-stalled-enabled',
|
39
|
+
'queue-stalled-minutes',
|
40
|
+
'rename-partial-files',
|
41
|
+
'rpc-version',
|
42
|
+
'rpc-version-minimum',
|
43
|
+
'script-torrent-done-filename',
|
44
|
+
'script-torrent-done-enabled',
|
45
|
+
'done',
|
46
|
+
'seedRatioLimit',
|
47
|
+
'seedRatioLimited',
|
48
|
+
'seed-queue-size',
|
49
|
+
'seed-queue-enabled',
|
50
|
+
'speed-limit-down',
|
51
|
+
'speed-limit-down-enabled',
|
52
|
+
'speed-limit-up',
|
53
|
+
'speed-limit-up-enabled',
|
54
|
+
'start-added-torrents',
|
55
|
+
'trash-original-torrent-files',
|
56
|
+
'units',
|
57
|
+
'utp-enabled',
|
58
|
+
'version'
|
59
|
+
]
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Transmission
|
2
|
+
class Arguments
|
3
|
+
class SessionSet < Transmission::Arguments
|
4
|
+
|
5
|
+
ATTRIBUTES = [
|
6
|
+
'alt-speed-down',
|
7
|
+
'alt-speed-enabled',
|
8
|
+
'alt-speed-time-begin',
|
9
|
+
'alt-speed-time-enabled',
|
10
|
+
'alt-speed-time-end',
|
11
|
+
'alt-speed-time-day',
|
12
|
+
'alt-speed-up',
|
13
|
+
'blocklist-url',
|
14
|
+
'blocklist-update',
|
15
|
+
'blocklist-enabled',
|
16
|
+
'cache-size-mb',
|
17
|
+
'download-dir',
|
18
|
+
'download-queue-size',
|
19
|
+
'download-queue-enabled',
|
20
|
+
'dht-enabled',
|
21
|
+
'encryption',
|
22
|
+
'required',
|
23
|
+
'preferred',
|
24
|
+
'tolerated',
|
25
|
+
'idle-seeding-limit',
|
26
|
+
'idle-seeding-limit-enabled',
|
27
|
+
'incomplete-dir',
|
28
|
+
'incomplete-dir-enabled',
|
29
|
+
'lpd-enabled',
|
30
|
+
'peer-limit-global',
|
31
|
+
'peer-limit-per-torrent',
|
32
|
+
'pex-enabled',
|
33
|
+
'peer-port',
|
34
|
+
'peer-port-random-on-start',
|
35
|
+
'port-forwarding-enabled',
|
36
|
+
'queue-stalled-enabled',
|
37
|
+
'queue-stalled-minutes',
|
38
|
+
'rename-partial-files',
|
39
|
+
'script-torrent-done-filename',
|
40
|
+
'script-torrent-done-enabled',
|
41
|
+
'done',
|
42
|
+
'seedRatioLimit',
|
43
|
+
'seedRatioLimited',
|
44
|
+
'seed-queue-size',
|
45
|
+
'seed-queue-enabled',
|
46
|
+
'speed-limit-down',
|
47
|
+
'speed-limit-down-enabled',
|
48
|
+
'speed-limit-up',
|
49
|
+
'speed-limit-up-enabled',
|
50
|
+
'start-added-torrents',
|
51
|
+
'trash-original-torrent-files',
|
52
|
+
'units',
|
53
|
+
'utp-enabled'
|
54
|
+
]
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Transmission
|
2
|
+
class Arguments
|
3
|
+
class SessionStats < Transmission::Arguments
|
4
|
+
|
5
|
+
ATTRIBUTES = [
|
6
|
+
'activeTorrentCount',
|
7
|
+
'downloadSpeed',
|
8
|
+
'pausedTorrentCount',
|
9
|
+
'torrentCount',
|
10
|
+
'uploadSpeed',
|
11
|
+
'cumulative-stats',
|
12
|
+
'current-stats'
|
13
|
+
]
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Transmission
|
2
|
+
class Arguments
|
3
|
+
class TorrentAdd < Transmission::Arguments
|
4
|
+
|
5
|
+
ATTRIBUTES = [
|
6
|
+
'cookies',
|
7
|
+
'download-dir',
|
8
|
+
'filename',
|
9
|
+
'metainfo',
|
10
|
+
'paused',
|
11
|
+
'peer-limit',
|
12
|
+
'bandwidthPriority',
|
13
|
+
'files-wanted',
|
14
|
+
'files-unwanted',
|
15
|
+
'priority-high',
|
16
|
+
'priority-low',
|
17
|
+
'priority-normal'
|
18
|
+
]
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Transmission
|
2
|
+
class Arguments
|
3
|
+
class TorrentGet < Transmission::Arguments
|
4
|
+
|
5
|
+
ATTRIBUTES = [
|
6
|
+
'id',
|
7
|
+
'activityDate',
|
8
|
+
'addedDate',
|
9
|
+
'bandwidthPriority',
|
10
|
+
'comment',
|
11
|
+
'corruptEver',
|
12
|
+
'creator',
|
13
|
+
'dateCreated',
|
14
|
+
'desiredAvailable',
|
15
|
+
'doneDate',
|
16
|
+
'downloadDir',
|
17
|
+
'downloadedEver',
|
18
|
+
'downloadLimit',
|
19
|
+
'downloadLimited',
|
20
|
+
'error',
|
21
|
+
'errorString',
|
22
|
+
'eta',
|
23
|
+
'etaIdle',
|
24
|
+
'files',
|
25
|
+
'fileStats',
|
26
|
+
'hashString',
|
27
|
+
'haveUnchecked',
|
28
|
+
'haveValid',
|
29
|
+
'honorsSessionLimits',
|
30
|
+
'isFinished',
|
31
|
+
'isPrivate',
|
32
|
+
'isStalled',
|
33
|
+
'leftUntilDone',
|
34
|
+
'magnetLink',
|
35
|
+
'manualAnnounceTime',
|
36
|
+
'maxConnectedPeers',
|
37
|
+
'metadataPercentComplete',
|
38
|
+
'name',
|
39
|
+
'peer-limit',
|
40
|
+
'peers',
|
41
|
+
'peersConnected',
|
42
|
+
'peersFrom',
|
43
|
+
'peersGettingFromUs',
|
44
|
+
'peersSendingToUs',
|
45
|
+
'percentDone',
|
46
|
+
'pieces',
|
47
|
+
'pieceCount',
|
48
|
+
'pieceSize',
|
49
|
+
'priorities',
|
50
|
+
'queuePosition',
|
51
|
+
'rateDownload',
|
52
|
+
'rateUpload',
|
53
|
+
'recheckProgress',
|
54
|
+
'secondsDownloading',
|
55
|
+
'secondsSeeding',
|
56
|
+
'seedIdleLimit',
|
57
|
+
'seedIdleMode',
|
58
|
+
'seedRatioLimit',
|
59
|
+
'seedRatioMode',
|
60
|
+
'sizeWhenDone',
|
61
|
+
'startDate',
|
62
|
+
'status',
|
63
|
+
'trackers',
|
64
|
+
'trackerStats',
|
65
|
+
'totalSize',
|
66
|
+
'torrentFile',
|
67
|
+
'uploadedEver',
|
68
|
+
'uploadLimit',
|
69
|
+
'uploadLimited',
|
70
|
+
'uploadRatio',
|
71
|
+
'wanted',
|
72
|
+
'webseeds',
|
73
|
+
'webseedsSendingToUs'
|
74
|
+
]
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|