transmission-rss 1.0.0.alpha1 → 1.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +12 -4
- data/bin/transmission-add-file +2 -2
- data/bin/transmission-rss +8 -3
- data/lib/transmission-rss/config.rb +22 -4
- data/lib/transmission-rss/log.rb +27 -15
- data/lib/transmission-rss/seen_file.rb +10 -8
- data/lib/transmission-rss/version.rb +1 -1
- data/transmission-rss.conf.example +12 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6549e5b8d06f19b6c8ff392677d66f0a5519ac73d39192522388eb0ed2b1bceb
|
4
|
+
data.tar.gz: 0fbd398d1a32c27b573a45228cdfd8b920010a627b3f3e46461a6ecd981750bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e14bfa9e9f86b4e52e1738d55752fa852bb4416eb0827be329db5688d5c13f1ca75a6f11df23388d5ed5242110b5704260fbf7ba460b28c06495062b742f3302
|
7
|
+
data.tar.gz: cfe725811a2ecbe457dfbda0451f59e99b6da4c5b48343db4753d7c4897976336b7c0d20eb45a6a6443284b7fea29bcda507990c62b6e40fe16dbce3b3d3b623
|
data/README.md
CHANGED
@@ -52,6 +52,10 @@ can override some options for their transmission-rss instances by providing a
|
|
52
52
|
config at `~/.config/transmission-rss/config.yml` (or in `$XDG_CONFIG_HOME`
|
53
53
|
instead of `~/.config`).
|
54
54
|
|
55
|
+
**WARNING:** If you want to override a nested option like `log.target` you also
|
56
|
+
have to explicitly specify the others like `log.level`. (True for categories
|
57
|
+
`server`, `login`, `log`, `privileges`, and `client`.)
|
58
|
+
|
55
59
|
### Minimal example
|
56
60
|
|
57
61
|
It should at least contain a list of feeds:
|
@@ -90,12 +94,14 @@ is true:
|
|
90
94
|
### All available options
|
91
95
|
|
92
96
|
The following configuration file example contains every existing option
|
93
|
-
(although `update_interval`, `add_paused`, `server`, `fork`, and
|
94
|
-
default values and could be omitted). The default `
|
95
|
-
`privileges` is not defined by default, so the script runs as current
|
97
|
+
(although `update_interval`, `add_paused`, `server`, `log`, `fork`, and
|
98
|
+
`pid_file` are default values and could be omitted). The default `log.target` is
|
99
|
+
STDERR. `privileges` is not defined by default, so the script runs as current
|
96
100
|
user/group. `login` is also not defined by default. It has to be defined, if
|
97
101
|
transmission is configured for HTTP basic authentication.
|
98
102
|
|
103
|
+
See `./transmission-rss.conf.example` for more documentation.
|
104
|
+
|
99
105
|
feeds:
|
100
106
|
- url: http://example.com/feed1
|
101
107
|
- url: http://example.com/feed2
|
@@ -133,7 +139,9 @@ transmission is configured for HTTP basic authentication.
|
|
133
139
|
username: transmission
|
134
140
|
password: transmission
|
135
141
|
|
136
|
-
|
142
|
+
log:
|
143
|
+
target: /var/log/transmissiond-rss.log
|
144
|
+
level: debug
|
137
145
|
|
138
146
|
privileges:
|
139
147
|
user: nobody
|
data/bin/transmission-add-file
CHANGED
@@ -46,12 +46,12 @@ config = TransmissionRSS::Config.instance
|
|
46
46
|
|
47
47
|
# Initialize a log instance and configure it.
|
48
48
|
log = Log.instance
|
49
|
-
log.target = config.log_target
|
50
49
|
|
51
50
|
# Load config file (default or given by argument).
|
52
51
|
begin
|
53
52
|
config.load(config_file)
|
54
|
-
log.target = config.
|
53
|
+
log.target = config.log.target
|
54
|
+
log.level = config.log.level
|
55
55
|
rescue Errno::ENOENT
|
56
56
|
log.error(config_file + ' not found')
|
57
57
|
end
|
data/bin/transmission-rss
CHANGED
@@ -77,12 +77,12 @@ config = TransmissionRSS::Config.instance
|
|
77
77
|
|
78
78
|
# Initialize a log instance and configure it.
|
79
79
|
log = Log.instance
|
80
|
-
log.target = config.log_target
|
81
80
|
|
82
81
|
# Load config file (default or given by argument).
|
83
82
|
begin
|
84
83
|
config.load(config_file)
|
85
|
-
log.target = config.
|
84
|
+
log.target = config.log.target
|
85
|
+
log.level = config.log.level
|
86
86
|
rescue Errno::ENOENT
|
87
87
|
log.error(config_file + ' not found')
|
88
88
|
end
|
@@ -100,7 +100,7 @@ if !(custom_config || ENV['HOME'].nil?)
|
|
100
100
|
end
|
101
101
|
|
102
102
|
# Print current config.
|
103
|
-
log.
|
103
|
+
log.info('transmission-rss ' + VERSION)
|
104
104
|
log.debug(config)
|
105
105
|
|
106
106
|
# Fork value from command line.
|
@@ -156,6 +156,11 @@ end
|
|
156
156
|
# Callback for changes to the config.
|
157
157
|
config.on_change do
|
158
158
|
aggregator.reinitialize!(config.feeds, seen_file: config.seen_file)
|
159
|
+
|
160
|
+
if reset_seen_file
|
161
|
+
aggregator.seen.clear!
|
162
|
+
log.debug('seenfile reset after config change')
|
163
|
+
end
|
159
164
|
end
|
160
165
|
|
161
166
|
# Start the aggregation process.
|
@@ -8,6 +8,10 @@ require File.join(libdir, 'log')
|
|
8
8
|
require File.join(libdir, 'callback')
|
9
9
|
|
10
10
|
module TransmissionRSS
|
11
|
+
DEPRECATED = {
|
12
|
+
log_target: 'log.target'
|
13
|
+
}
|
14
|
+
|
11
15
|
# Class handles configuration parameters.
|
12
16
|
class Config < Hash
|
13
17
|
# This is a singleton class.
|
@@ -24,15 +28,17 @@ module TransmissionRSS
|
|
24
28
|
end
|
25
29
|
|
26
30
|
# Merges a Hash or YAML file (containing a Hash) with itself.
|
27
|
-
def load(config)
|
31
|
+
def load(config, watch: true)
|
28
32
|
case config.class.to_s
|
29
33
|
when 'Hash'
|
30
34
|
self.merge!(config)
|
31
35
|
when 'String'
|
32
|
-
self.merge_yaml!(config)
|
36
|
+
self.merge_yaml!(config, watch)
|
33
37
|
else
|
34
38
|
raise ArgumentError.new('Could not load config.')
|
35
39
|
end
|
40
|
+
|
41
|
+
check_deprecated
|
36
42
|
end
|
37
43
|
|
38
44
|
def merge_defaults!
|
@@ -46,7 +52,10 @@ module TransmissionRSS
|
|
46
52
|
'rpc_path' => '/transmission/rpc'
|
47
53
|
},
|
48
54
|
'login' => nil,
|
49
|
-
'
|
55
|
+
'log' => {
|
56
|
+
'target' => $stderr,
|
57
|
+
'level' => :debug
|
58
|
+
},
|
50
59
|
'fork' => false,
|
51
60
|
'pid_file' => false,
|
52
61
|
'privileges' => {},
|
@@ -70,7 +79,6 @@ module TransmissionRSS
|
|
70
79
|
|
71
80
|
def watch_file(path)
|
72
81
|
path = Pathname.new(path).realpath.to_s
|
73
|
-
@log.debug('watch_file ' + path)
|
74
82
|
|
75
83
|
@notifier ||= INotify::Notifier.new
|
76
84
|
@notifier.watch(path, :close_write) do |e|
|
@@ -87,5 +95,15 @@ module TransmissionRSS
|
|
87
95
|
@notifier.run
|
88
96
|
end
|
89
97
|
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def check_deprecated
|
102
|
+
DEPRECATED.each do |key, value|
|
103
|
+
if self[key.to_s]
|
104
|
+
@log.warn('[DEPRECATED] option %s, use %s' % [key, value])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
90
108
|
end
|
91
109
|
end
|
data/lib/transmission-rss/log.rb
CHANGED
@@ -6,30 +6,42 @@ module TransmissionRSS
|
|
6
6
|
class Log
|
7
7
|
include Singleton
|
8
8
|
|
9
|
-
def initialize(target = $stderr)
|
10
|
-
|
11
|
-
@
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@logger.formatter = proc do |sev, time, _, msg|
|
19
|
-
time = time.strftime('%Y-%m-%d %H:%M:%S')
|
20
|
-
"#{time} (#{sev.downcase}) #{msg}\n"
|
21
|
-
end
|
9
|
+
def initialize(target = $stderr, level = :debug)
|
10
|
+
@target = target
|
11
|
+
@level = level
|
12
|
+
|
13
|
+
@logger = Logger.new(target)
|
14
|
+
@logger.level = to_level_const(level)
|
15
|
+
@logger.formatter = proc do |sev, time, _, msg|
|
16
|
+
time = time.strftime('%Y-%m-%d %H:%M:%S')
|
17
|
+
"#{time} (#{sev.downcase}) #{msg}\n"
|
22
18
|
end
|
23
19
|
end
|
24
20
|
|
25
|
-
# Change log target (IO
|
21
|
+
# Change log target (IO, path to a file as String, or Symbol for IO
|
22
|
+
# constant).
|
26
23
|
def target=(target)
|
27
|
-
|
24
|
+
if target.is_a? Symbol
|
25
|
+
target = Object.const_get(target.to_s.upcase)
|
26
|
+
end
|
27
|
+
|
28
|
+
initialize(target, @level)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Change log level (String or Symbol)
|
32
|
+
def level=(level)
|
33
|
+
initialize(@target, level)
|
28
34
|
end
|
29
35
|
|
30
36
|
# If this class misses a method, call it on the encapsulated Logger class.
|
31
37
|
def method_missing(sym, *args)
|
32
38
|
@logger.send(sym, *args)
|
33
39
|
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def to_level_const(level)
|
44
|
+
Object.const_get('Logger::' + level.to_s.upcase)
|
45
|
+
end
|
34
46
|
end
|
35
47
|
end
|
@@ -7,18 +7,12 @@ module TransmissionRSS
|
|
7
7
|
# Persist seen torrent URLs
|
8
8
|
class SeenFile
|
9
9
|
extend ::Forwardable
|
10
|
-
|
11
|
-
DEFAULT_LEGACY_PATH =
|
12
|
-
File.join(Etc.getpwuid.dir, '.config/transmission/seen-torrents.conf')
|
13
|
-
|
14
|
-
DEFAULT_PATH =
|
15
|
-
File.join(Etc.getpwuid.dir, '.config/transmission/seen')
|
16
10
|
|
17
11
|
def_delegators :@seen, :size, :to_a
|
18
12
|
|
19
13
|
def initialize(path = nil, legacy_path = nil)
|
20
|
-
@legacy_path = legacy_path ||
|
21
|
-
@path = path ||
|
14
|
+
@legacy_path = legacy_path || default_legacy_path
|
15
|
+
@path = path || default_path
|
22
16
|
|
23
17
|
initialize_path!
|
24
18
|
migrate!
|
@@ -49,6 +43,14 @@ module TransmissionRSS
|
|
49
43
|
|
50
44
|
private
|
51
45
|
|
46
|
+
def default_legacy_path
|
47
|
+
File.join(Etc.getpwuid.dir, '.config/transmission/seen-torrents.conf')
|
48
|
+
end
|
49
|
+
|
50
|
+
def default_path
|
51
|
+
File.join(Etc.getpwuid.dir, '.config/transmission/seen')
|
52
|
+
end
|
53
|
+
|
52
54
|
def digest(s)
|
53
55
|
Digest::SHA256.hexdigest(s)
|
54
56
|
end
|
@@ -2,6 +2,11 @@
|
|
2
2
|
# Indent consistently with spaces!
|
3
3
|
# Format documentation on http://www.yaml.org/.
|
4
4
|
#
|
5
|
+
# WARNING:
|
6
|
+
# If you want to override a nested option like `log.target` you also have to
|
7
|
+
# explicitly specify the others like `log.level`. (True for categories
|
8
|
+
# `server`, `login`, `log`, `privileges`, and `client`.)
|
9
|
+
#
|
5
10
|
|
6
11
|
# List of feeds to watch.
|
7
12
|
|
@@ -48,9 +53,14 @@ feeds:
|
|
48
53
|
# username: transmission
|
49
54
|
# password: transmission
|
50
55
|
|
51
|
-
# Where to log. Default is stderr.
|
56
|
+
# Where to log. Default target is stderr, level debug. Target can be IO symbol
|
57
|
+
# (e.g. ":stderr", ":stdout") or file path (e.g.
|
58
|
+
# "/var/log/transmission-rss.log"). Level can be "error", "warn", "info",
|
59
|
+
# "debug".
|
52
60
|
|
53
|
-
#
|
61
|
+
#log:
|
62
|
+
# target: :stderr
|
63
|
+
# level: debug
|
54
64
|
|
55
65
|
# Drop privileges. If omitted, privileges are not dropped.
|
56
66
|
|
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: 1.0.0.
|
4
|
+
version: 1.0.0.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- henning mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open_uri_redirections
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.2'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.1
|
22
|
+
version: 0.2.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
29
|
+
version: '0.2'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.1
|
32
|
+
version: 0.2.1
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rb-inotify
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '0.9'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.9.
|
42
|
+
version: 0.9.10
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '0.9'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.9.
|
52
|
+
version: 0.9.10
|
53
53
|
description: |-
|
54
54
|
transmission-rss is basically a workaround for
|
55
55
|
transmission's lack of the ability to monitor RSS feeds and
|
@@ -86,7 +86,7 @@ require_paths:
|
|
86
86
|
- lib
|
87
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - "
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '2.1'
|
92
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: 1.3.1
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.6
|
99
|
+
rubygems_version: 2.7.6
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Adds torrents from rss feeds to transmission web frontend.
|