transmission-rss 0.1.16 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/bin/transmission-rss +3 -5
- data/lib/transmission-rss.rb +0 -1
- data/lib/transmission-rss/aggregator.rb +26 -7
- data/lib/transmission-rss/version.rb +3 -0
- data/transmission-rss.conf.example +4 -0
- 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: e7e1bf28fdb759f8d433c1ab15ceb2c59fa5bb98
|
4
|
+
data.tar.gz: 5e0d3988ea752b949716104b70a2f704f210a25d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db7212ccb20446d868dd936fa614e5cd0b74a6d06982f9616bf302ae9a37ac3912347acb394f0f64fa769e45a97979384a88370956380f6abd102c188a9747cd
|
7
|
+
data.tar.gz: 77020f6fc537c01e199dc2e76323aeec34579ce91ffd11adaf127624b5f645b1f2def24124e4b03eecc3edfb6bba3bbdb0af6da9ebf64d71b1ac2cecaec80d79
|
data/README.md
CHANGED
@@ -41,6 +41,14 @@ It should at least contain a list of feeds:
|
|
41
41
|
- http://example.com/feed1
|
42
42
|
- http://example.com/feed2
|
43
43
|
|
44
|
+
Feed item titles can be filtered by a regular expression:
|
45
|
+
|
46
|
+
feeds:
|
47
|
+
- http://example.com/feed1:
|
48
|
+
regexp: foo
|
49
|
+
- http://example.com/feed2:
|
50
|
+
regexp: (foo|bar)
|
51
|
+
|
44
52
|
### All available options
|
45
53
|
|
46
54
|
The following configuration file example contains every existing option
|
@@ -51,6 +59,10 @@ not defined by default, so the script runs as current user/group.
|
|
51
59
|
feeds:
|
52
60
|
- http://example.com/feed1
|
53
61
|
- http://example.com/feed2
|
62
|
+
- http://example.com/feed3:
|
63
|
+
regexp: match1
|
64
|
+
- http://example.com/feed4:
|
65
|
+
regexp: (match1|match2)
|
54
66
|
|
55
67
|
update_interval: 600
|
56
68
|
|
data/bin/transmission-rss
CHANGED
@@ -73,7 +73,8 @@ defaults = {
|
|
73
73
|
'log_target' => $stderr,
|
74
74
|
'fork' => false,
|
75
75
|
'pid_file' => false,
|
76
|
-
'privileges' => {}
|
76
|
+
'privileges' => {},
|
77
|
+
'seen_file' => nil
|
77
78
|
}
|
78
79
|
config.load defaults
|
79
80
|
|
@@ -126,14 +127,11 @@ trap 'HUP' do
|
|
126
127
|
end
|
127
128
|
|
128
129
|
# Initialize feed aggregator.
|
129
|
-
aggregator = Aggregator.new
|
130
|
+
aggregator = Aggregator.new(config.feeds, seen_file: config.seen_file)
|
130
131
|
|
131
132
|
# Initialize communication to transmission.
|
132
133
|
client = Client.new config.server.host, config.server.port
|
133
134
|
|
134
|
-
# Add feeds from config file to +Aggregator+ class.
|
135
|
-
aggregator.feeds.concat config.feeds
|
136
|
-
|
137
135
|
# Callback for a new item on one of the feeds.
|
138
136
|
aggregator.on_new_item do |torrent_file|
|
139
137
|
client.add_torrent torrent_file, :url, config.add_paused
|
data/lib/transmission-rss.rb
CHANGED
@@ -14,19 +14,26 @@ module TransmissionRSS
|
|
14
14
|
extend Callback
|
15
15
|
callback :on_new_item # Declare callback for new items.
|
16
16
|
|
17
|
-
|
17
|
+
def initialize(feeds = [], seen_file: nil)
|
18
|
+
# Prepare Array of feeds URLs.
|
19
|
+
@feeds = feeds.map { |x| x.is_a?(Hash) ? x.keys.first : x }
|
20
|
+
|
21
|
+
# Prepare Hash of feed URL => Regexp filter.
|
22
|
+
@filters = feeds.select { |x| x.is_a? Hash }
|
23
|
+
@filters = @filters.map do |x|
|
24
|
+
[x.keys.first, Regexp.new(x['regexp'], Regexp::IGNORECASE)]
|
25
|
+
end
|
26
|
+
@filters = Hash[@filters]
|
18
27
|
|
19
|
-
|
20
|
-
@feeds = feeds
|
28
|
+
# Nothing seen, yet.
|
21
29
|
@seen = []
|
22
30
|
|
23
31
|
# Initialize log instance.
|
24
32
|
@log = Log.instance
|
25
33
|
|
26
34
|
# Generate path for seen torrents store file.
|
27
|
-
@seenfile = File.join
|
28
|
-
|
29
|
-
'/.config/transmission/seen-torrents.conf'
|
35
|
+
@seenfile = seen_file || File.join(Etc.getpwuid.dir,
|
36
|
+
'/.config/transmission/seen-torrents.conf')
|
30
37
|
|
31
38
|
# Make directories in path if they are not existing.
|
32
39
|
FileUtils.mkdir_p File.dirname(@seenfile)
|
@@ -51,7 +58,7 @@ module TransmissionRSS
|
|
51
58
|
@log.debug 'aggregator start'
|
52
59
|
|
53
60
|
while true
|
54
|
-
feeds.each do |url|
|
61
|
+
@feeds.each do |url|
|
55
62
|
url = URI.encode(url)
|
56
63
|
@log.debug 'aggregate ' + url
|
57
64
|
|
@@ -74,7 +81,19 @@ module TransmissionRSS
|
|
74
81
|
|
75
82
|
# The link is not in +@seen+ Array.
|
76
83
|
unless seen? link
|
84
|
+
# @log.debug 'unseen link ' + link
|
85
|
+
|
86
|
+
# Skip if filter defined and not matching.
|
87
|
+
if @filters.include? url
|
88
|
+
unless item.title[@filters[url]]
|
89
|
+
# @log.debug 'filter does not match ' + item.title
|
90
|
+
add_seen link
|
91
|
+
next
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
77
95
|
@log.debug 'on_new_item event ' + link
|
96
|
+
|
78
97
|
begin
|
79
98
|
on_new_item link
|
80
99
|
rescue Errno::ECONNREFUSED
|
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.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- henning mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open_uri_redirections
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- lib/transmission-rss/config.rb
|
52
52
|
- lib/transmission-rss/hash.rb
|
53
53
|
- lib/transmission-rss/log.rb
|
54
|
+
- lib/transmission-rss/version.rb
|
54
55
|
- transmission-rss.conf.example
|
55
56
|
homepage: https://rubygems.org/gems/transmission-rss
|
56
57
|
licenses:
|