rootor 0.0.5 → 0.0.6
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/README.md +13 -6
- data/lib/client.rb +4 -0
- data/lib/rootor.rb +8 -3
- data/lib/torrent.rb +7 -20
- 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: 941a719fe6d5ca4530fd4ad85390c55de5277762
|
4
|
+
data.tar.gz: ac8b9b6862d1e35255bd7001e24ac99d0cc5ad24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9afaf2eeb76c8652b8169b4173d293240cbde0e391d8270116eb57cef22737f3e4c5865536ec8ae07130cafce1896c4411cd7be6189ee45d49da45ed01f3eca9
|
7
|
+
data.tar.gz: 25da29ba999103eefd9a14c655e8439f8da75a889ccbe7d29f707d304460a7592a624ac66abb77ad0434c4fd861c7cfa4ff664cd0309c7ddaafe0b50975abf25
|
data/README.md
CHANGED
@@ -1,24 +1,31 @@
|
|
1
|
-
Rootor is an `
|
1
|
+
Rootor is an `XMLRPC` client rtorrent ruby interface.
|
2
2
|
```bash
|
3
3
|
gem install rootor
|
4
4
|
```
|
5
5
|
|
6
|
-
|
7
6
|
```ruby
|
8
7
|
require 'rootor'
|
9
8
|
|
10
9
|
r = Rootor.new('https://<user>:<password>@<server>:<port>/<xmlrpc>')
|
11
10
|
|
12
|
-
|
11
|
+
# get all your torrents
|
12
|
+
r.torrents
|
13
|
+
|
14
|
+
# make them more digestible
|
15
|
+
r.torrents.serialize
|
16
|
+
|
17
|
+
# find best one
|
18
|
+
r.torrents.sort_by(&:ratio).last
|
13
19
|
|
20
|
+
# add a new torrent
|
14
21
|
r.load_from_file('<file.torrent>')
|
15
22
|
```
|
16
23
|
|
17
|
-
Reference
|
24
|
+
Reference material
|
18
25
|
---
|
19
|
-
https://
|
26
|
+
https://ruby-doc.org/stdlib-2.3.1/libdoc/xmlrpc/rdoc/XMLRPC/Client.html
|
20
27
|
|
21
|
-
|
28
|
+
https://github.com/mdevaev/emonoda/wiki/rTorrent-XMLRPC-Reference
|
22
29
|
|
23
30
|
https://github.com/rakshasa/rtorrent/wiki/rTorrent-0.9-Comprehensive-Command-list-(WIP)
|
24
31
|
|
data/lib/client.rb
CHANGED
data/lib/rootor.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'xmlrpc/client'
|
2
2
|
require 'filesize'
|
3
|
+
require 'json'
|
3
4
|
require_relative 'client'
|
4
5
|
require_relative 'torrent'
|
5
6
|
require_relative 'queries'
|
@@ -8,7 +9,7 @@ class Rootor
|
|
8
9
|
attr_accessor :client, :torrents
|
9
10
|
|
10
11
|
def initialize(xmlrpc_url)
|
11
|
-
@client
|
12
|
+
@client = Client.new2(xmlrpc_url)
|
12
13
|
@torrents = refresh!
|
13
14
|
end
|
14
15
|
|
@@ -20,8 +21,8 @@ class Rootor
|
|
20
21
|
@torrents.map(&:serialize)
|
21
22
|
end
|
22
23
|
|
23
|
-
def
|
24
|
-
|
24
|
+
def json_torrents
|
25
|
+
serialized_torrents.to_json
|
25
26
|
end
|
26
27
|
|
27
28
|
def find(str)
|
@@ -35,6 +36,10 @@ class Rootor
|
|
35
36
|
@client.load_start(XMLRPC::Base64.new(data))
|
36
37
|
end
|
37
38
|
|
39
|
+
def remove(hash)
|
40
|
+
@client.erase(hash)
|
41
|
+
end
|
42
|
+
|
38
43
|
def load_from_file(path)
|
39
44
|
load_from_raw(File.read(path))
|
40
45
|
end
|
data/lib/torrent.rb
CHANGED
@@ -7,40 +7,27 @@ class Torrent
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
def serialize
|
10
|
+
def serialize
|
11
11
|
serialized_queries = Hash[
|
12
12
|
@raw_hash.map do |k, v|
|
13
13
|
[
|
14
14
|
k,
|
15
|
-
mutate(FLAT_QUERIES[k][:kind], v
|
15
|
+
mutate(FLAT_QUERIES[k][:kind], v)
|
16
16
|
]
|
17
17
|
end
|
18
18
|
]
|
19
19
|
|
20
|
-
serialized_queries.merge(
|
21
|
-
|
22
|
-
|
23
|
-
}
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
def pretty_serialize
|
28
|
-
serialize(pretty: true)
|
20
|
+
serialized_queries.merge({
|
21
|
+
tracker: URI(serialized_queries[:tracker_url]).host
|
22
|
+
})
|
29
23
|
end
|
30
24
|
|
31
25
|
private
|
32
26
|
|
33
|
-
def mutate(kase, data
|
27
|
+
def mutate(kase, data)
|
34
28
|
case kase
|
35
|
-
when :file
|
36
|
-
filesize = Filesize.from("#{data} B")
|
37
|
-
pretty ? filesize.pretty : filesize
|
38
|
-
when :rate
|
39
|
-
filesize = Filesize.from("#{data} B")
|
40
|
-
pretty ? "#{filesize.pretty}/s" : filesize
|
41
29
|
when :time
|
42
|
-
|
43
|
-
pretty ? time.to_s : time
|
30
|
+
Time.at(data).to_i
|
44
31
|
when :ratio
|
45
32
|
data.to_f / 1000
|
46
33
|
when :int
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rootor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- graham otte
|
@@ -11,7 +11,7 @@ cert_chain: []
|
|
11
11
|
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|