transmission-rss 0.1.24 → 0.1.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -10
- data/bin/transmission-add-file +1 -1
- data/bin/transmission-rss +2 -2
- data/lib/transmission-rss/aggregator.rb +9 -20
- data/lib/transmission-rss/client.rb +3 -2
- data/lib/transmission-rss/feed.rb +20 -0
- data/lib/transmission-rss/version.rb +1 -1
- data/transmission-rss.conf.example +6 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa641fabb07e0f42ffb837d7c89fe363d6a39512
|
4
|
+
data.tar.gz: b0824327608585661139d792dd5273ec72e39069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72965be8fee0e2b989bcb55c2973aff2784d4a0f170e342455225abc83d6cf620d5cb0665e1adc1690d2795d6047cdbbc033f4f34f23f879686144d640dda867
|
7
|
+
data.tar.gz: a647e5865cdae78072bb8d8401cd87abc2db1057914e52d75e62a5cffc9ab6500505cacfeae46725fefee7b267fd53c9d2a3cf9414e975aa76bb5ffdd3472cc6
|
data/README.md
CHANGED
@@ -43,17 +43,23 @@ instead of `~/.config`).
|
|
43
43
|
It should at least contain a list of feeds:
|
44
44
|
|
45
45
|
feeds:
|
46
|
-
- http://example.com/feed1
|
47
|
-
- http://example.com/feed2
|
46
|
+
- url: http://example.com/feed1
|
47
|
+
- url: http://example.com/feed2
|
48
48
|
|
49
49
|
Feed item titles can be filtered by a regular expression:
|
50
50
|
|
51
51
|
feeds:
|
52
|
-
- http://example.com/feed1
|
52
|
+
- url: http://example.com/feed1
|
53
53
|
regexp: foo
|
54
|
-
- http://example.com/feed2
|
54
|
+
- url: http://example.com/feed2
|
55
55
|
regexp: (foo|bar)
|
56
56
|
|
57
|
+
Feeds can also be configured to download files to specific directory:
|
58
|
+
|
59
|
+
feeds:
|
60
|
+
- url: http://example.com/feed1:
|
61
|
+
download_path: /home/user/Downloads
|
62
|
+
|
57
63
|
### All available options
|
58
64
|
|
59
65
|
The following configuration file example contains every existing option
|
@@ -64,12 +70,14 @@ user/group. `login` is also not defined by default. It has to be defined, if
|
|
64
70
|
transmission is configured for HTTP basic authentication.
|
65
71
|
|
66
72
|
feeds:
|
67
|
-
- http://example.com/feed1
|
68
|
-
- http://example.com/feed2
|
69
|
-
- http://example.com/feed3
|
73
|
+
- url: http://example.com/feed1
|
74
|
+
- url: http://example.com/feed2
|
75
|
+
- url: http://example.com/feed3
|
70
76
|
regexp: match1
|
71
|
-
- http://example.com/feed4
|
77
|
+
- url: http://example.com/feed4
|
72
78
|
regexp: (match1|match2)
|
79
|
+
- url: http://example.com/feed4
|
80
|
+
download_path: /home/user/Downloads
|
73
81
|
|
74
82
|
update_interval: 600
|
75
83
|
|
@@ -103,12 +111,12 @@ Remember checking the path in `ExecStart`.
|
|
103
111
|
[Unit]
|
104
112
|
Description=Transmission RSS daemon.
|
105
113
|
After=network.target transmission-daemon.service
|
106
|
-
|
114
|
+
|
107
115
|
[Service]
|
108
116
|
Type=forking
|
109
117
|
ExecStart=/usr/local/bin/transmission-rss -f
|
110
118
|
ExecReload=/bin/kill -s HUP $MAINPID
|
111
|
-
|
119
|
+
|
112
120
|
[Install]
|
113
121
|
WantedBy=multi-user.target
|
114
122
|
|
data/bin/transmission-add-file
CHANGED
@@ -78,7 +78,7 @@ log.debug(config)
|
|
78
78
|
client = Client.new(config.server.host, config.server.port)
|
79
79
|
|
80
80
|
ARGV.each do |torrent_file|
|
81
|
-
client.add_torrent(torrent_file, :file, config.add_paused)
|
81
|
+
client.add_torrent(torrent_file, :file, paused: config.add_paused)
|
82
82
|
end
|
83
83
|
|
84
84
|
log.close
|
data/bin/transmission-rss
CHANGED
@@ -150,8 +150,8 @@ aggregator = Aggregator.new(config.feeds, seen_file: config.seen_file)
|
|
150
150
|
client = Client.new(config.server.host, config.server.port, config.login)
|
151
151
|
|
152
152
|
# Callback for a new item on one of the feeds.
|
153
|
-
aggregator.on_new_item do |torrent_file|
|
154
|
-
client.add_torrent(torrent_file, :url, config.add_paused)
|
153
|
+
aggregator.on_new_item do |torrent_file, feed|
|
154
|
+
client.add_torrent(torrent_file, :url, paused: config.add_paused, download_path: feed.download_path)
|
155
155
|
end
|
156
156
|
|
157
157
|
# Save PID.
|
@@ -18,14 +18,7 @@ module TransmissionRSS
|
|
18
18
|
seen_file = options[:seen_file]
|
19
19
|
|
20
20
|
# Prepare Array of feeds URLs.
|
21
|
-
@feeds = feeds.map { |
|
22
|
-
|
23
|
-
# Prepare Hash of feed URL => Regexp filter.
|
24
|
-
@filters = feeds.select { |x| x.is_a? Hash }
|
25
|
-
@filters = @filters.map do |x|
|
26
|
-
[x.keys.first, Regexp.new(x['regexp'], Regexp::IGNORECASE)]
|
27
|
-
end
|
28
|
-
@filters = Hash[@filters]
|
21
|
+
@feeds = feeds.map { |config| TransmissionRSS::Feed.new(config) }
|
29
22
|
|
30
23
|
# Nothing seen, yet.
|
31
24
|
@seen = []
|
@@ -60,12 +53,11 @@ module TransmissionRSS
|
|
60
53
|
@log.debug('aggregator start')
|
61
54
|
|
62
55
|
while true
|
63
|
-
@feeds.each do |
|
64
|
-
|
65
|
-
@log.debug('aggregate ' + url)
|
56
|
+
@feeds.each do |feed|
|
57
|
+
@log.debug('aggregate ' + feed.url)
|
66
58
|
|
67
59
|
begin
|
68
|
-
content = open(url, allow_redirections: :safe).read
|
60
|
+
content = open(feed.url, allow_redirections: :safe).read
|
69
61
|
rescue Exception => e
|
70
62
|
@log.debug("retrieval error (#{e.class}: #{e.message})")
|
71
63
|
next
|
@@ -74,7 +66,6 @@ module TransmissionRSS
|
|
74
66
|
# gzip HTTP Content-Encoding is not automatically decompressed in
|
75
67
|
# Ruby 1.9.3.
|
76
68
|
content = decompress(content) if RUBY_VERSION == '1.9.3'
|
77
|
-
|
78
69
|
begin
|
79
70
|
items = RSS::Parser.parse(content, false).items
|
80
71
|
rescue Exception => e
|
@@ -84,7 +75,7 @@ module TransmissionRSS
|
|
84
75
|
|
85
76
|
items.each do |item|
|
86
77
|
link = item.enclosure.url rescue item.link
|
87
|
-
|
78
|
+
|
88
79
|
# Item contains no link.
|
89
80
|
next if link.nil?
|
90
81
|
|
@@ -94,17 +85,15 @@ module TransmissionRSS
|
|
94
85
|
# The link is not in +@seen+ Array.
|
95
86
|
unless seen?(link)
|
96
87
|
# Skip if filter defined and not matching.
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
next
|
101
|
-
end
|
88
|
+
unless feed.matches_regexp?(item.title)
|
89
|
+
add_seen(link)
|
90
|
+
next
|
102
91
|
end
|
103
92
|
|
104
93
|
@log.debug('on_new_item event ' + link)
|
105
94
|
|
106
95
|
begin
|
107
|
-
on_new_item(link)
|
96
|
+
on_new_item(link, feed)
|
108
97
|
rescue Client::Unauthorized, Errno::ECONNREFUSED, Timeout::Error
|
109
98
|
# Do not add to seen file.
|
110
99
|
else
|
@@ -17,11 +17,12 @@ module TransmissionRSS
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# POST json packed torrent add command.
|
20
|
-
def add_torrent(file, type,
|
20
|
+
def add_torrent(file, type, options = {})
|
21
21
|
hash = {
|
22
22
|
'method' => 'torrent-add',
|
23
23
|
'arguments' => {
|
24
|
-
'paused' => paused
|
24
|
+
'paused' => options[:paused],
|
25
|
+
'download-dir' => options[:download_path]
|
25
26
|
}
|
26
27
|
}
|
27
28
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module TransmissionRSS
|
2
|
+
class Feed
|
3
|
+
attr_reader :url, :regexp, :download_path
|
4
|
+
|
5
|
+
def initialize(config = {})
|
6
|
+
case config
|
7
|
+
when Hash
|
8
|
+
@url = URI.encode(config['url'] || config.keys.first)
|
9
|
+
@regexp = Regexp.new(config['regexp'], Regexp::IGNORECASE) if config['regexp']
|
10
|
+
@download_path = config['download_path']
|
11
|
+
else
|
12
|
+
@url = config.to_s
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def matches_regexp?(title)
|
17
|
+
@regexp.nil? || !(title =~ @regexp).nil?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,12 +6,14 @@
|
|
6
6
|
# List of feeds to watch.
|
7
7
|
|
8
8
|
feeds:
|
9
|
-
- http://example.com/feed1
|
10
|
-
- http://example.com/feed2
|
11
|
-
- http://example.com/feed3
|
9
|
+
- url: http://example.com/feed1
|
10
|
+
- url: http://example.com/feed2
|
11
|
+
- url: http://example.com/feed3
|
12
12
|
regexp: match1
|
13
|
-
- http://example.com/feed4
|
13
|
+
- url: http://example.com/feed4
|
14
14
|
regexp: (match1|match2)
|
15
|
+
- url: http://example.com/feed4
|
16
|
+
download_path: /home/user/Downloads
|
15
17
|
|
16
18
|
# Feed probing interval in seconds. Default is 600.
|
17
19
|
|
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.1.
|
4
|
+
version: 0.1.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- henning mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open_uri_redirections
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/transmission-rss/callback.rb
|
50
50
|
- lib/transmission-rss/client.rb
|
51
51
|
- lib/transmission-rss/config.rb
|
52
|
+
- lib/transmission-rss/feed.rb
|
52
53
|
- lib/transmission-rss/hash.rb
|
53
54
|
- lib/transmission-rss/log.rb
|
54
55
|
- lib/transmission-rss/version.rb
|