transmission-rss 1.1.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac9f76bca685a810ed32c80d1e43b7252d10a0088d33d4826d5b4e6c1496d753
4
- data.tar.gz: b400a88f22877be316284d9edc0a3f13b73c014f16557adacaf2dc7fd9bc4004
3
+ metadata.gz: bb9c56c39e910b2887fc0125df3ccec3870ec9b42bc36ec40440f72dce9cf4d4
4
+ data.tar.gz: cfe742ea19cf4ff7f22bace81c5f24d14f70e6c25bb123e5b0d4d6f8693c261b
5
5
  SHA512:
6
- metadata.gz: 5c34f47be84831505bfdeacf16ec7ea07b38b520e86b0c25222583a667edc956a4846394355949780151cd26f180bfeac26583f437c5f2f4c7a641c7a2e748b3
7
- data.tar.gz: 27952ef90a8ca35e7fc1897a36610dc93c735d50be9a3f926821af141f2a241a85f6dbc5d19e45d0e42960f9579a1c1f7b0f6a2e434a81a0025edd04b5231d4a
6
+ metadata.gz: 7234a61c9cf5fb97b53484007d0e475f6349161cf022b95784cc7fc3a85b5f304060d3a9ac34470da6d85d5ed6325001b4f653eb0144020d8056994c62d5871d
7
+ data.tar.gz: d2ff27c562b7db9f2e161337065e8e69301df5a624608704adf0f8296abbd68ff24575abfc3a7ecaa5166b43b878833185bd8e3ab6d0248fe52c4153197149ea
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 -t \
44
- -v $(pwd)/transmission-rss.conf:/etc/transmission-rss.conf \
45
- nning2/transmission-rss:v1.0.0
51
+ ```sh
52
+ docker run -t \
53
+ -v $(pwd)/transmission-rss.conf:/etc/transmission-rss.conf \
54
+ nning2/transmission-rss:v1.2.1
55
+ ```
46
56
 
47
57
  Configuration
48
58
  -------------
@@ -60,36 +70,49 @@ 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
 
@@ -102,62 +125,65 @@ 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
- tls: false
137
- rpc_path: /transmission/rpc
138
-
139
- login:
140
- username: transmission
141
- password: transmission
142
-
143
- log:
144
- target: /var/log/transmissiond-rss.log
145
- level: debug
146
-
147
- privileges:
148
- user: nobody
149
- group: nobody
150
-
151
- client:
152
- timeout: 5
153
-
154
- fork: false
155
-
156
- single: false
157
-
158
- pid_file: false
159
-
160
- 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
+ ```
161
187
 
162
188
  Daemonized Startup
163
189
  ------------------
@@ -168,17 +194,19 @@ The following content can be saved into
168
194
  `/etc/systemd/system/transmission-rss.service` to create a systemd unit.
169
195
  Remember checking the path in `ExecStart`.
170
196
 
171
- [Unit]
172
- Description=Transmission RSS daemon.
173
- After=network.target transmission-daemon.service
197
+ ```ini
198
+ [Unit]
199
+ Description=Transmission RSS daemon.
200
+ After=network.target transmission-daemon.service
174
201
 
175
- [Service]
176
- Type=forking
177
- ExecStart=/usr/local/bin/transmission-rss -f
178
- 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
179
206
 
180
- [Install]
181
- WantedBy=multi-user.target
207
+ [Install]
208
+ WantedBy=multi-user.target
209
+ ```
182
210
 
183
211
  The unit files are reloaded by `systemctl daemon-reload`. You can then start
184
212
  transmission-rss by running `systemctl start transmission-rss`. Starting on
@@ -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
@@ -85,6 +78,25 @@ module TransmissionRSS
85
78
 
86
79
  private
87
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
+
88
100
  def decompress(string)
89
101
  Zlib::GzipReader.new(StringIO.new(string)).read
90
102
  rescue Zlib::GzipFile::Error, Zlib::Error
@@ -48,7 +48,7 @@ module TransmissionRSS
48
48
 
49
49
  case type
50
50
  when :url
51
- file = URI.encode(file) if URI.decode(file) == file
51
+ file = URI.escape(file) if URI.unescape(file) == file
52
52
  arguments.filename = file
53
53
  when :file
54
54
  arguments.metainfo = Base64.encode64(File.read(file))
@@ -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(URI.unescape(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.1.0'
2
+ VERSION = '1.2.2'
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
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.1.0
4
+ version: 1.2.2
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: 2019-09-30 00:00:00.000000000 Z
11
+ date: 2022-06-19 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
@@ -96,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
117
  - !ruby/object:Gem::Version
97
118
  version: '0'
98
119
  requirements: []
99
- rubygems_version: 3.0.3
100
- signing_key:
120
+ rubygems_version: 3.2.32
121
+ signing_key:
101
122
  specification_version: 4
102
123
  summary: Adds torrents from rss feeds to transmission web frontend.
103
124
  test_files: []