transmission-rss 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -7
- data/bin/transmission-rss +5 -1
- data/lib/transmission-rss/client.rb +56 -34
- data/lib/transmission-rss/feed.rb +3 -1
- data/lib/transmission-rss/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 395d3f0f34878429129d601628fe37e5d7753e1f
|
4
|
+
data.tar.gz: 76b962020543b7ec0c62a1d76d940f8dcc7c167f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f3bb43fb943b3085d17caa7e77251de1e0d63b04e43cd7653cd768de5d2a4179f3a158b3e9c5a1a93f8fdec1fb108130565622a4e2fbca8480b347a14160eb
|
7
|
+
data.tar.gz: 4e18d699f2c9dac769b01c5c38d8e16ac840ea26332318dc02cbc8a6e8e9c8298a4caa7184f1f48b8fded259a517149f7847e14f68c054acce378aa600f6aa67
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ Installation
|
|
32
32
|
|
33
33
|
git clone https://github.com/nning/transmission-rss
|
34
34
|
cd transmission-rss
|
35
|
-
|
35
|
+
bundle
|
36
36
|
gem build transmission-rss.gemspec
|
37
37
|
gem install transmission-rss-*.gem
|
38
38
|
|
@@ -66,6 +66,12 @@ Feeds can also be configured to download files to specific directory:
|
|
66
66
|
- url: http://example.com/feed1
|
67
67
|
download_path: /home/user/Downloads
|
68
68
|
|
69
|
+
Setting the seed ratio limit is supported per feed:
|
70
|
+
|
71
|
+
feeds:
|
72
|
+
- url: http://example.com/feed1
|
73
|
+
seed_ratio_limit: 0
|
74
|
+
|
69
75
|
### All available options
|
70
76
|
|
71
77
|
The following configuration file example contains every existing option
|
@@ -84,6 +90,8 @@ transmission is configured for HTTP basic authentication.
|
|
84
90
|
regexp: (match1|match2)
|
85
91
|
- url: http://example.com/feed4
|
86
92
|
download_path: /home/user/Downloads
|
93
|
+
- url: http://example.com/feed4
|
94
|
+
seed_ratio_limit: 1
|
87
95
|
- url: http://example.com/feed4
|
88
96
|
regexp:
|
89
97
|
- match1
|
@@ -91,9 +99,9 @@ transmission is configured for HTTP basic authentication.
|
|
91
99
|
- url: http://example.com/feed5
|
92
100
|
regexp:
|
93
101
|
- matcher: match1
|
94
|
-
|
102
|
+
download_path: /home/user/match1
|
95
103
|
- matcher: match2
|
96
|
-
|
104
|
+
download_path: /home/user/match2
|
97
105
|
|
98
106
|
update_interval: 600
|
99
107
|
|
@@ -104,9 +112,9 @@ transmission is configured for HTTP basic authentication.
|
|
104
112
|
port: 9091
|
105
113
|
rpc_path: /transmission/rpc
|
106
114
|
|
107
|
-
|
108
|
-
|
109
|
-
|
115
|
+
login:
|
116
|
+
username: transmission
|
117
|
+
password: transmission
|
110
118
|
|
111
119
|
log_target: /var/log/transmissiond-rss.log
|
112
120
|
|
@@ -118,7 +126,7 @@ transmission is configured for HTTP basic authentication.
|
|
118
126
|
|
119
127
|
pid_file: false
|
120
128
|
|
121
|
-
|
129
|
+
seen_file: ~/.config/transmission/seen
|
122
130
|
|
123
131
|
Daemonized Startup
|
124
132
|
------------------
|
data/bin/transmission-rss
CHANGED
@@ -99,6 +99,7 @@ if !(custom_config || ENV['HOME'].nil?)
|
|
99
99
|
end
|
100
100
|
|
101
101
|
# Print current config.
|
102
|
+
log.debug('version ' + VERSION)
|
102
103
|
log.debug(config)
|
103
104
|
|
104
105
|
# Fork value from command line.
|
@@ -145,7 +146,10 @@ client = Client.new(config.server, config.login)
|
|
145
146
|
|
146
147
|
# Callback for a new item on one of the feeds.
|
147
148
|
aggregator.on_new_item do |torrent_file, feed, download_path|
|
148
|
-
client.add_torrent(torrent_file, :url,
|
149
|
+
client.add_torrent(torrent_file, :url,
|
150
|
+
paused: config.add_paused,
|
151
|
+
download_path: download_path,
|
152
|
+
seed_ratio_limit: feed.config.seed_ratio_limit)
|
149
153
|
end
|
150
154
|
|
151
155
|
# Callback for changes to the config.
|
@@ -20,51 +20,69 @@ module TransmissionRSS
|
|
20
20
|
@log = TransmissionRSS::Log.instance
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
def rpc(method, arguments)
|
24
|
+
sid = get_session_id
|
25
|
+
raise Unauthorized unless sid
|
26
|
+
|
27
|
+
post = Net::HTTP::Post.new \
|
28
|
+
@rpc_path,
|
29
|
+
{
|
30
|
+
'Content-Type' => 'application/json',
|
31
|
+
'X-Transmission-Session-Id' => sid
|
30
32
|
}
|
33
|
+
|
34
|
+
add_basic_auth(post)
|
35
|
+
post.body = {method: method, arguments: arguments}.to_json
|
36
|
+
|
37
|
+
JSON.parse(request(post).body)
|
38
|
+
end
|
39
|
+
|
40
|
+
# POST json packed torrent add command.
|
41
|
+
def add_torrent(file, type = :url, options = {})
|
42
|
+
arguments = {
|
43
|
+
'paused' => options[:paused],
|
44
|
+
'download-dir' => options[:download_path]
|
31
45
|
}
|
32
46
|
|
33
47
|
case type
|
34
48
|
when :url
|
35
|
-
|
49
|
+
arguments.filename = file
|
36
50
|
when :file
|
37
|
-
|
51
|
+
arguments.metainfo = Base64.encode64(File.read(file))
|
38
52
|
else
|
39
53
|
raise ArgumentError.new('type has to be :url or :file.')
|
40
54
|
end
|
41
55
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
post = Net::HTTP::Post.new \
|
46
|
-
@rpc_path,
|
47
|
-
{
|
48
|
-
'Content-Type' => 'application/json',
|
49
|
-
'X-Transmission-Session-Id' => sid
|
50
|
-
}
|
56
|
+
response = rpc('torrent-add', arguments)
|
57
|
+
id = get_id_from_response(response)
|
51
58
|
|
52
|
-
|
59
|
+
log_message = 'torrent-add result: ' + response.result
|
60
|
+
log_message << ' (id ' + id.to_s + ')' if id
|
61
|
+
@log.debug(log_message)
|
53
62
|
|
54
|
-
|
63
|
+
if id && options[:seed_ratio_limit]
|
64
|
+
set_torrent(id, {
|
65
|
+
'seedRatioLimit': options[:seed_ratio_limit].to_f,
|
66
|
+
'seedRatioMode': 1
|
67
|
+
})
|
68
|
+
end
|
55
69
|
|
56
|
-
response
|
70
|
+
response
|
71
|
+
end
|
57
72
|
|
58
|
-
|
73
|
+
def set_torrent(id, arguments = {})
|
74
|
+
arguments.ids = [id]
|
75
|
+
response = rpc('torrent-set', arguments)
|
76
|
+
@log.debug('torrent-set result: ' + response.result)
|
59
77
|
|
60
|
-
|
78
|
+
response
|
61
79
|
end
|
62
80
|
|
63
81
|
# Get transmission session id.
|
64
82
|
def get_session_id
|
65
83
|
get = Net::HTTP::Get.new(@rpc_path)
|
66
84
|
|
67
|
-
|
85
|
+
add_basic_auth(get)
|
68
86
|
|
69
87
|
response = request(get)
|
70
88
|
|
@@ -82,9 +100,19 @@ module TransmissionRSS
|
|
82
100
|
|
83
101
|
private
|
84
102
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
103
|
+
def add_basic_auth(request)
|
104
|
+
return if @login.nil?
|
105
|
+
request.basic_auth(@login['username'], @login['password'])
|
106
|
+
end
|
107
|
+
|
108
|
+
def get_id_from_response(response)
|
109
|
+
response.arguments.first.last.id
|
110
|
+
rescue
|
111
|
+
end
|
112
|
+
|
113
|
+
def http_request(data)
|
114
|
+
Net::HTTP.new(@host, @port).start do |http|
|
115
|
+
http.request(data)
|
88
116
|
end
|
89
117
|
end
|
90
118
|
|
@@ -93,7 +121,7 @@ module TransmissionRSS
|
|
93
121
|
|
94
122
|
Timeout.timeout(@timeout) do
|
95
123
|
@log.debug("request #@host:#@port")
|
96
|
-
|
124
|
+
http_request(data)
|
97
125
|
end
|
98
126
|
rescue Errno::ECONNREFUSED
|
99
127
|
@log.debug('connection refused')
|
@@ -108,11 +136,5 @@ module TransmissionRSS
|
|
108
136
|
|
109
137
|
raise
|
110
138
|
end
|
111
|
-
|
112
|
-
def http_get(data)
|
113
|
-
Net::HTTP.new(@host, @port).start do |http|
|
114
|
-
http.request(data)
|
115
|
-
end
|
116
|
-
end
|
117
139
|
end
|
118
140
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module TransmissionRSS
|
2
2
|
class Feed
|
3
|
-
attr_reader :url, :regexp
|
3
|
+
attr_reader :url, :regexp, :config
|
4
4
|
|
5
5
|
def initialize(config = {})
|
6
6
|
@download_paths = {}
|
7
7
|
|
8
8
|
case config
|
9
9
|
when Hash
|
10
|
+
@config = config
|
11
|
+
|
10
12
|
@url = URI.encode(config['url'] || config.keys.first)
|
11
13
|
|
12
14
|
@download_path = config['download_path']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transmission-rss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- henning mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open_uri_redirections
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.6.
|
99
|
+
rubygems_version: 2.6.8
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Adds torrents from rss feeds to transmission web frontend.
|