transmission-rss 1.0.0.beta1 → 1.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06335ae55c5547575753c5e83595a32918b5acf583ee8a89e6ccbd4ba016dcac
4
- data.tar.gz: b6132be027c0be9bfd3570a0d39f0230bbeade5d0aa9a34e5d6c2e157c0acce0
3
+ metadata.gz: e93a561f40bd628318cf507101b393624547251369fc6cc0557f280afaabf194
4
+ data.tar.gz: f743d335aac56c1130ae2fd6c85f6d6a2f8ee0cd91ad8128df0309d97b880de9
5
5
  SHA512:
6
- metadata.gz: 83ab6f33442032dda0d7366291b91ab70cd866e8d2666bb49489ade302a3ca41010fef97a04af0e8fce2572a8be0c4a3f335b7ba52a34e9bb46b6e1e8ca553a9
7
- data.tar.gz: 0deda4306c1937d5124344566c51f155f2b7befa1cff4a7dc67ac740ca854a033ff32d0da21ad2e4b3165a45afb350c3b41c792bd44a14198773d4a306ffad01
6
+ metadata.gz: af81937243076628a610f49f6f28dfccbfeba3377964705c976e870f1e9c496ae9c03c50d16fb834823ccb258ccbe78bafd33502670e49900935ab1f0971d81f
7
+ data.tar.gz: c0e00180d4c23177d92d004ca08a8b53a40cb22bd09e6e3231acc7f0b60865c1750e236f72bcbc58aa1935193dd6364e82ef8ff408c1edc7af41c99e12e299b1
data/README.md CHANGED
@@ -23,26 +23,36 @@ code to the single most delightful human being: Ann.
23
23
  The minimum supported Ruby version is 2.1. (You will need `rbenv` if your
24
24
  os does not support Ruby >= 2.1, e.g. on Debian wheezy.)
25
25
 
26
+ **Note, that this README is for the current development branch!** You can find
27
+ a link to a suitable README for your version
28
+ [on the releases page](https://github.com/nning/transmission-rss/releases).
29
+
26
30
  Installation
27
31
  ------------
28
32
 
29
33
  ### Latest stable version from rubygems.org
30
34
 
31
- gem install transmission-rss
35
+ ```sh
36
+ gem install transmission-rss
37
+ ```
32
38
 
33
39
  ### From source
34
40
 
35
- git clone https://github.com/nning/transmission-rss
36
- cd transmission-rss
37
- bundle
38
- gem build transmission-rss.gemspec
39
- gem install transmission-rss-*.gem
41
+ ```sh
42
+ git clone https://github.com/nning/transmission-rss
43
+ cd transmission-rss
44
+ bundle
45
+ gem build transmission-rss.gemspec
46
+ gem install transmission-rss-*.gem
47
+ ```
40
48
 
41
49
  ### Via Docker
42
50
 
43
- docker run \
44
- -v $(pwd)/transmission-rss.conf:/etc/transmission-rss.conf \
45
- nning2/transmission-rss
51
+ ```sh
52
+ docker run -t \
53
+ -v $(pwd)/transmission-rss.conf:/etc/transmission-rss.conf \
54
+ nning2/transmission-rss:v1.0.0
55
+ ```
46
56
 
47
57
  Configuration
48
58
  -------------
@@ -60,41 +70,54 @@ have to explicitly specify the others like `log.level`. (True for categories
60
70
 
61
71
  It should at least contain a list of feeds:
62
72
 
63
- feeds:
64
- - url: http://example.com/feed1
65
- - url: http://example.com/feed2
73
+ ```yaml
74
+ feeds:
75
+ - url: http://example.com/feed1
76
+ - url: http://example.com/feed2
77
+ ```
66
78
 
67
79
  Feed item titles can be filtered by a regular expression:
68
80
 
69
- feeds:
70
- - url: http://example.com/feed1
71
- regexp: foo
72
- - url: http://example.com/feed2
73
- regexp: (foo|bar)
81
+ ```yaml
82
+ feeds:
83
+ - url: http://example.com/feed1
84
+ regexp: foo
85
+ - url: http://example.com/feed2
86
+ regexp: (foo|bar)
87
+ ```
74
88
 
75
89
  Feeds can also be configured to download files to specific directory:
76
90
 
77
- feeds:
78
- - url: http://example.com/feed1
79
- download_path: /home/user/Downloads
91
+
92
+ ```yaml
93
+ feeds:
94
+ - url: http://example.com/feed1
95
+ download_path: /home/user/Downloads
96
+ ```
80
97
 
81
98
  Setting the seed ratio limit is supported per feed:
82
99
 
83
- feeds:
84
- - url: http://example.com/feed1
85
- seed_ratio_limit: 0
100
+
101
+ ```yaml
102
+ feeds:
103
+ - url: http://example.com/feed1
104
+ seed_ratio_limit: 0
105
+ ```
86
106
 
87
107
  Configurable certificate validation, good for self-signed certificates. Default
88
108
  is true:
89
109
 
90
- feeds:
91
- - url: http://example.com/feed1
92
- validate_cert: false
110
+
111
+ ```yaml
112
+ feeds:
113
+ - url: http://example.com/feed1
114
+ validate_cert: false
115
+ ```
93
116
 
94
117
  ### All available options
95
118
 
96
119
  The following configuration file example contains every existing option
97
- (although `update_interval`, `add_paused`, `server`, `log`, `fork`, and
120
+ (although `update_interval`, `add_paused`, `server`, `log`, `fork`, `single`, and
98
121
  `pid_file` are default values and could be omitted). The default `log.target` is
99
122
  STDERR. `privileges` is not defined by default, so the script runs as current
100
123
  user/group. `login` is also not defined by default. It has to be defined, if
@@ -102,79 +125,95 @@ transmission is configured for HTTP basic authentication.
102
125
 
103
126
  See `./transmission-rss.conf.example` for more documentation.
104
127
 
105
- feeds:
106
- - url: http://example.com/feed1
107
- - url: http://example.com/feed2
108
- - url: http://example.com/feed3
109
- regexp: match1
110
- - url: http://example.com/feed4
111
- regexp: (match1|match2)
112
- - url: http://example.com/feed5
113
- download_path: /home/user/Downloads
114
- - url: http://example.com/feed6
115
- seed_ratio_limit: 1
116
- - url: http://example.com/feed7
117
- regexp:
118
- - match1
119
- - match2
120
- - url: http://example.com/feed8
121
- regexp:
122
- - matcher: match1
123
- download_path: /home/user/match1
124
- - matcher: match2
125
- download_path: /home/user/match2
126
- - url: http://example.com/feed9
127
- validate_cert: false
128
-
129
- update_interval: 600
130
-
131
- add_paused: false
132
-
133
- server:
134
- host: localhost
135
- port: 9091
136
- rpc_path: /transmission/rpc
137
-
138
- login:
139
- username: transmission
140
- password: transmission
141
-
142
- log:
143
- target: /var/log/transmissiond-rss.log
144
- level: debug
145
-
146
- privileges:
147
- user: nobody
148
- group: nobody
149
-
150
- client:
151
- timeout: 5
152
-
153
- fork: false
154
-
155
- pid_file: false
156
-
157
- seen_file: ~/.config/transmission/seen
128
+
129
+ ```yaml
130
+ feeds:
131
+ - url: http://example.com/feed1
132
+ - url: http://example.com/feed2
133
+ - url: http://example.com/feed3
134
+ regexp: match1
135
+ - url: http://example.com/feed4
136
+ regexp: (match1|match2)
137
+ - url: http://example.com/feed5
138
+ download_path: /home/user/Downloads
139
+ - url: http://example.com/feed6
140
+ seed_ratio_limit: 1
141
+ - url: http://example.com/feed7
142
+ regexp:
143
+ - match1
144
+ - match2
145
+ - url: http://example.com/feed8
146
+ regexp:
147
+ - matcher: match1
148
+ download_path: /home/user/match1
149
+ - matcher: match2
150
+ download_path: /home/user/match2
151
+ - url: http://example.com/feed9
152
+ validate_cert: false
153
+
154
+ update_interval: 600
155
+
156
+ add_paused: false
157
+
158
+ server:
159
+ host: localhost
160
+ port: 9091
161
+ tls: false
162
+ rpc_path: /transmission/rpc
163
+
164
+ login:
165
+ username: transmission
166
+ password: transmission
167
+
168
+ log:
169
+ target: /var/log/transmissiond-rss.log
170
+ level: debug
171
+
172
+ privileges:
173
+ user: nobody
174
+ group: nobody
175
+
176
+ client:
177
+ timeout: 5
178
+
179
+ fork: false
180
+
181
+ single: false
182
+
183
+ pid_file: false
184
+
185
+ seen_file: ~/.config/transmission/seen
186
+ ```
158
187
 
159
188
  Daemonized Startup
160
189
  ------------------
161
190
 
191
+ ### As a systemd service
192
+
162
193
  The following content can be saved into
163
194
  `/etc/systemd/system/transmission-rss.service` to create a systemd unit.
164
195
  Remember checking the path in `ExecStart`.
165
196
 
166
- [Unit]
167
- Description=Transmission RSS daemon.
168
- After=network.target transmission-daemon.service
197
+ ```ini
198
+ [Unit]
199
+ Description=Transmission RSS daemon.
200
+ After=network.target transmission-daemon.service
169
201
 
170
- [Service]
171
- Type=forking
172
- ExecStart=/usr/local/bin/transmission-rss -f
173
- ExecReload=/bin/kill -s HUP $MAINPID
202
+ [Service]
203
+ Type=forking
204
+ ExecStart=/usr/local/bin/transmission-rss -f
205
+ ExecReload=/bin/kill -s HUP $MAINPID
174
206
 
175
- [Install]
176
- WantedBy=multi-user.target
207
+ [Install]
208
+ WantedBy=multi-user.target
209
+ ```
177
210
 
178
211
  The unit files are reloaded by `systemctl daemon-reload`. You can then start
179
212
  transmission-rss by running `systemctl start transmission-rss`. Starting on
180
213
  boot, can be enabled `systemctl enable transmission-rss`.
214
+
215
+ ### As a cronjob
216
+
217
+ `transmission-rss` can also be started in a single run mode, in which it runs a single loop and then exits. To do so, `transmission-rss` needs to be started with the `-s` flag. An example crontab line for running every 10 minutes can be:
218
+
219
+ `*/10 * * * * /usr/local/bin/transmission-rss -s`
data/bin/transmission-rss CHANGED
@@ -20,6 +20,9 @@ end
20
20
  # Do not fork by default.
21
21
  dofork = false
22
22
 
23
+ # Do not run single time by default.
24
+ dosingle = false
25
+
23
26
  # No PID file by default.
24
27
  pid_file = false
25
28
 
@@ -33,6 +36,7 @@ Adds torrents from rss feeds to transmission web frontend.
33
36
 
34
37
  -c <file> Custom config file path. Default: #{config_file}
35
38
  -f Fork into background after startup.
39
+ -s Single run mode.
36
40
  -h This help.
37
41
  -p <file> Write PID to file.
38
42
  -r Reset seenfile on startup.
@@ -46,6 +50,7 @@ end
46
50
  options = GetoptLong.new \
47
51
  ['-c', GetoptLong::REQUIRED_ARGUMENT],
48
52
  ['-f', GetoptLong::NO_ARGUMENT],
53
+ ['-s', GetoptLong::NO_ARGUMENT],
49
54
  ['-h', GetoptLong::NO_ARGUMENT],
50
55
  ['-p', GetoptLong::REQUIRED_ARGUMENT],
51
56
  ['-r', GetoptLong::NO_ARGUMENT],
@@ -59,6 +64,8 @@ options.each do |option, argument|
59
64
  custom_config = true
60
65
  when '-f'
61
66
  dofork = true
67
+ when '-s'
68
+ dosingle = true
62
69
  when '-h'
63
70
  usage_message(config_file)
64
71
  when '-p'
@@ -106,6 +113,9 @@ log.debug(config)
106
113
  # Fork value from command line.
107
114
  config.fork = dofork if dofork
108
115
 
116
+ # Run a single time.
117
+ config.single = dosingle if dosingle
118
+
109
119
  # PID file path from command line.
110
120
  config.pid_file = pid_file if pid_file
111
121
 
@@ -174,6 +184,8 @@ begin
174
184
  log.debug('wrote pid to ' + config.pid_file)
175
185
  File.write(config.pid_file, pid)
176
186
  end
187
+ elsif config.single
188
+ aggregator.run(-1)
177
189
  else
178
190
  log.debug('pid ' + Process.pid.to_s)
179
191
 
@@ -44,15 +44,8 @@ module TransmissionRSS
44
44
  @feeds.each do |feed|
45
45
  @log.debug('aggregate ' + feed.url)
46
46
 
47
- options = {allow_redirections: :safe}
48
-
49
- unless feed.validate_cert
50
- @log.debug('aggregate certificate validation: false')
51
- options[:ssl_verify_mode] = OpenSSL::SSL::VERIFY_NONE
52
- end
53
-
54
47
  begin
55
- content = open(feed.url, options).read
48
+ content = fetch(feed)
56
49
  rescue StandardError => e
57
50
  @log.debug("retrieval error (#{e.class}: #{e.message})")
58
51
  next
@@ -62,7 +55,7 @@ module TransmissionRSS
62
55
  # Ruby 1.9.3.
63
56
  content = decompress(content) if RUBY_VERSION == '1.9.3'
64
57
  begin
65
- items = RSS::Parser.parse(content, false).items
58
+ items = parse(content)
66
59
  rescue StandardError => e
67
60
  @log.debug("parse error (#{e.class}: #{e.message})")
68
61
  next
@@ -74,12 +67,36 @@ module TransmissionRSS
74
67
  end
75
68
  end
76
69
 
70
+ if interval == -1
71
+ @log.debug('single run mode, exiting')
72
+ break
73
+ end
74
+
77
75
  sleep(interval)
78
76
  end
79
77
  end
80
78
 
81
79
  private
82
80
 
81
+ def fetch(feed)
82
+ options = {
83
+ allow_redirections: :safe,
84
+ 'User-Agent' => 'transmission-rss'
85
+ }
86
+
87
+ unless feed.validate_cert
88
+ @log.debug('aggregate certificate validation: false')
89
+ options[:ssl_verify_mode] = OpenSSL::SSL::VERIFY_NONE
90
+ end
91
+
92
+ # open for URIs is obsolete, URI.open does not work in 2.4
93
+ URI.send(:open, feed.url, options).read
94
+ end
95
+
96
+ def parse(content)
97
+ RSS::Parser.parse(content, false).items
98
+ end
99
+
83
100
  def decompress(string)
84
101
  Zlib::GzipReader.new(StringIO.new(string)).read
85
102
  rescue Zlib::GzipFile::Error, Zlib::Error
@@ -17,6 +17,7 @@ module TransmissionRSS
17
17
 
18
18
  @host = server.host || 'localhost'
19
19
  @port = server.port || 9091
20
+ @tls = !!server.tls
20
21
  @rpc_path = server.rpc_path || '/transmission/rpc'
21
22
  @login = login
22
23
 
@@ -47,6 +48,7 @@ module TransmissionRSS
47
48
 
48
49
  case type
49
50
  when :url
51
+ file = URI.escape(file) if URI.unescape(file) == file
50
52
  arguments.filename = file
51
53
  when :file
52
54
  arguments.metainfo = Base64.encode64(File.read(file))
@@ -112,7 +114,7 @@ module TransmissionRSS
112
114
  end
113
115
 
114
116
  def http_request(data)
115
- Net::HTTP.new(@host, @port).start do |http|
117
+ Net::HTTP.start(@host, @port, use_ssl: @tls) do |http|
116
118
  http.request(data)
117
119
  end
118
120
  end
@@ -52,6 +52,7 @@ module TransmissionRSS
52
52
  'server' => {
53
53
  'host' => 'localhost',
54
54
  'port' => 9091,
55
+ 'tls' => false,
55
56
  'rpc_path' => '/transmission/rpc'
56
57
  },
57
58
  'login' => nil,
@@ -60,6 +61,7 @@ module TransmissionRSS
60
61
  'level' => :debug
61
62
  },
62
63
  'fork' => false,
64
+ 'single' => false,
63
65
  'pid_file' => false,
64
66
  'privileges' => {},
65
67
  'seen_file' => nil
@@ -0,0 +1,9 @@
1
+ module URI
2
+ def self.escape(*arg)
3
+ URI::DEFAULT_PARSER.escape(*arg)
4
+ end
5
+
6
+ def self.unescape(*arg)
7
+ URI::DEFAULT_PARSER.unescape(*arg)
8
+ end
9
+ end
@@ -9,7 +9,7 @@ module TransmissionRSS
9
9
  when Hash
10
10
  @config = config
11
11
 
12
- @url = URI.encode(config['url'] || config.keys.first)
12
+ @url = URI.escape(config['url'] || config.keys.first)
13
13
 
14
14
  @download_path = config['download_path']
15
15
  @validate_cert = config['validate_cert'].nil? || config['validate_cert']
@@ -7,22 +7,19 @@ module TransmissionRSS
7
7
  # Persist seen torrent URLs
8
8
  class SeenFile
9
9
  extend ::Forwardable
10
-
11
- def_delegators :@seen, :size, :to_a
12
10
 
13
- def initialize(path = nil, legacy_path = nil)
14
- @legacy_path = legacy_path || default_legacy_path
15
- @path = path || default_path
11
+ def_delegators :@seen, :size, :to_a
16
12
 
17
- initialize_path!
18
- migrate!
13
+ def initialize(path = nil)
14
+ @path = path || default_path
15
+ initialize_path!(@path)
19
16
 
20
17
  @seen = Set.new(file_to_array(@path))
21
18
  end
22
19
 
23
20
  def add(url)
24
21
  hash = digest(url)
25
-
22
+
26
23
  return if @seen.include?(hash)
27
24
 
28
25
  @seen << hash
@@ -43,10 +40,6 @@ module TransmissionRSS
43
40
 
44
41
  private
45
42
 
46
- def default_legacy_path
47
- File.join(Etc.getpwuid.dir, '.config/transmission/seen-torrents.conf')
48
- end
49
-
50
43
  def default_path
51
44
  File.join(Etc.getpwuid.dir, '.config/transmission/seen')
52
45
  end
@@ -59,25 +52,11 @@ module TransmissionRSS
59
52
  open(path, 'r').readlines.map(&:chomp)
60
53
  end
61
54
 
62
- def initialize_path!
63
- return if File.exist?(@path)
64
-
65
- FileUtils.mkdir_p(File.dirname(@path))
66
- FileUtils.touch(@path)
67
- end
68
-
69
- def migrate!
70
- return unless File.exist?(@legacy_path)
71
-
72
- legacy_seen = file_to_array(@legacy_path)
73
- hashes = legacy_seen.map { |url| digest(url) }
74
-
75
- open(@path, 'w') do |f|
76
- f.write(hashes.join("\n"))
77
- f.write("\n")
78
- end
55
+ def initialize_path!(path)
56
+ return if File.exist?(path)
79
57
 
80
- FileUtils.rm_f(@legacy_path)
58
+ FileUtils.mkdir_p(File.dirname(path))
59
+ FileUtils.touch(path)
81
60
  end
82
61
  end
83
62
  end
@@ -1,3 +1,3 @@
1
1
  module TransmissionRSS
2
- VERSION = '1.0.0.beta1'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -5,6 +5,7 @@ end
5
5
 
6
6
  require 'transmission-rss/core_ext/Array'
7
7
  require 'transmission-rss/core_ext/Object'
8
+ require 'transmission-rss/core_ext/URI'
8
9
 
9
10
  Dir.glob($:.first + '/**/*.rb').each do |lib|
10
11
  require lib
@@ -77,6 +77,10 @@ feeds:
77
77
 
78
78
  #fork: false
79
79
 
80
+ # Single run mode?
81
+
82
+ # single: false
83
+
80
84
  # Save PID.
81
85
 
82
86
  #pid_file: false
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transmission-rss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - henning mueller
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-16 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rss
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.2.9
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.2.9
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: open_uri_redirections
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +92,7 @@ files:
72
92
  - lib/transmission-rss/core_ext/Array.rb
73
93
  - lib/transmission-rss/core_ext/Hash.rb
74
94
  - lib/transmission-rss/core_ext/Object.rb
95
+ - lib/transmission-rss/core_ext/URI.rb
75
96
  - lib/transmission-rss/feed.rb
76
97
  - lib/transmission-rss/log.rb
77
98
  - lib/transmission-rss/seen_file.rb
@@ -81,7 +102,7 @@ homepage: https://rubygems.org/gems/transmission-rss
81
102
  licenses:
82
103
  - GPL-3.0
83
104
  metadata: {}
84
- post_install_message:
105
+ post_install_message:
85
106
  rdoc_options: []
86
107
  require_paths:
87
108
  - lib
@@ -92,13 +113,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
113
  version: '2.1'
93
114
  required_rubygems_version: !ruby/object:Gem::Requirement
94
115
  requirements:
95
- - - ">"
116
+ - - ">="
96
117
  - !ruby/object:Gem::Version
97
- version: 1.3.1
118
+ version: '0'
98
119
  requirements: []
99
- rubyforge_project:
100
- rubygems_version: 2.7.6
101
- signing_key:
120
+ rubygems_version: 3.2.22
121
+ signing_key:
102
122
  specification_version: 4
103
123
  summary: Adds torrents from rss feeds to transmission web frontend.
104
124
  test_files: []