transmission-rss 0.1.5 → 0.1.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.
data/bin/transmission-rss
CHANGED
@@ -140,9 +140,9 @@ client = Client.new(config.server.host, config.server.port)
|
|
140
140
|
aggregator.feeds.concat(config.feeds)
|
141
141
|
|
142
142
|
# Callback for a new item on one of the feeds.
|
143
|
-
aggregator.on_new_item do |
|
143
|
+
aggregator.on_new_item do |torrent_file|
|
144
144
|
Thread.start do
|
145
|
-
client.
|
145
|
+
client.add_torrent(torrent_file, config.add_paused)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
data/lib/transmission-rss.rb
CHANGED
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
require 'timeout'
|
4
4
|
|
5
5
|
# TODO
|
6
|
-
# * Why the hell do timeouts in
|
6
|
+
# * Why the hell do timeouts in get_session_id and add_torrent not work?!
|
7
7
|
|
8
8
|
# Class for communication with transmission utilizing the RPC web interface.
|
9
9
|
class TransmissionRSS::Client
|
@@ -15,7 +15,7 @@ class TransmissionRSS::Client
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# Get transmission session id by simple GET.
|
18
|
-
def
|
18
|
+
def get_session_id
|
19
19
|
get = Net::HTTP::Get.new(
|
20
20
|
'/transmission/rpc'
|
21
21
|
)
|
@@ -46,12 +46,12 @@ class TransmissionRSS::Client
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# POST json packed torrent add command.
|
49
|
-
def
|
49
|
+
def add_torrent(torrent_file, paused = false)
|
50
50
|
post = Net::HTTP::Post.new(
|
51
51
|
'/transmission/rpc',
|
52
52
|
initheader = {
|
53
53
|
'Content-Type' => 'application/json',
|
54
|
-
'X-Transmission-Session-Id' =>
|
54
|
+
'X-Transmission-Session-Id' => get_session_id
|
55
55
|
}
|
56
56
|
)
|
57
57
|
|
@@ -59,7 +59,7 @@ class TransmissionRSS::Client
|
|
59
59
|
"method" => "torrent-add",
|
60
60
|
"arguments" => {
|
61
61
|
"paused" => paused,
|
62
|
-
"filename" =>
|
62
|
+
"filename" => torrent_file
|
63
63
|
}
|
64
64
|
}.to_json
|
65
65
|
|
@@ -83,6 +83,6 @@ class TransmissionRSS::Client
|
|
83
83
|
|
84
84
|
result = JSON.parse(response.body).result
|
85
85
|
|
86
|
-
@log.debug('
|
86
|
+
@log.debug('add_torrent result: ' + result)
|
87
87
|
end
|
88
88
|
end
|
@@ -16,8 +16,8 @@ class TransmissionRSS::ConfigEditor
|
|
16
16
|
}
|
17
17
|
|
18
18
|
# Loads glade file and initializes dynamic GUI elements.
|
19
|
-
def initialize(
|
20
|
-
@configFile =
|
19
|
+
def initialize(config_file, config)
|
20
|
+
@configFile = config_file
|
21
21
|
@config = config
|
22
22
|
|
23
23
|
path = File.join(File.dirname(__FILE__), 'main.glade')
|