transmission-rss 0.2.6 → 1.0.0.alpha1

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
  SHA1:
3
- metadata.gz: 493cecb752e1c3a5bbb092cdbde8c28cb6f16a42
4
- data.tar.gz: a0fc2fefd52f20222de0d2fcb53ec91c8c19e92c
3
+ metadata.gz: 054764ff1a7340698a20d891b084e2a3763898be
4
+ data.tar.gz: cd4df944492cfb88e2602be7b02adac5ff3a93e9
5
5
  SHA512:
6
- metadata.gz: a8fcb2eef302a7682b6897f8e083a1e9cb21e4b5ec4059e678fa710e97c407a70d21bb6f815455147cf5965dba222aa25f97a4f1880d34f0086a7fb5117d9ce9
7
- data.tar.gz: a452c783869832ef8c2aa0f24ba05f6a28eef56ae08d03bf5f10c3123e1c211a7fe99a3bac9ec8e315cd7adc1a360e1fcfeb0309716b81f09e5038261ad4db37
6
+ metadata.gz: 5ca44ab44a99dee02cb406a5a8e537136a95c64fc1193f74b34aa80a248288ad3cc5823367adaa4a2a6af605d3129a45eac14c97fe7178811c7a9b59af4f671b
7
+ data.tar.gz: a5031c612c6d8b5c8677ab338ed27c48c0095bae7829df1b908b591f4d34b5b8e8c20a70aa7c655d82e7985d4f2cc37e32b0f66b80cfe1a3954b131c1d8bff8b
data/README.md CHANGED
@@ -4,7 +4,8 @@ transmission-rss
4
4
  [![Gem Version](https://img.shields.io/gem/v/transmission-rss.svg)](http://badge.fury.io/rb/transmission-rss)
5
5
  [![Build Status](https://img.shields.io/travis/nning/transmission-rss/master.svg)](https://travis-ci.org/nning/transmission-rss)
6
6
  [![Coverage Status](https://img.shields.io/coveralls/nning/transmission-rss/master.svg)](https://coveralls.io/r/nning/transmission-rss)
7
- [![Code Climate](https://img.shields.io/codeclimate/github/nning/transmission-rss.svg)](https://codeclimate.com/github/nning/transmission-rss)
7
+ [![Code Climate](https://img.shields.io/codeclimate/maintainability/nning/transmission-rss.svg)](https://codeclimate.com/github/nning/transmission-rss)
8
+ [![Docker Hub Build Status](https://img.shields.io/docker/build/nning2/transmission-rss.svg)](https://hub.docker.com/r/nning2/transmission-rss/)
8
9
 
9
10
  transmission-rss is basically a workaround for transmission's lack of the
10
11
  ability to monitor RSS feeds and automatically add enclosed torrent links.
@@ -19,7 +20,8 @@ torrent files.
19
20
  As it's done with poems, I devote this very artful and romantic piece of
20
21
  code to the single most delightful human being: Ann.
21
22
 
22
- The minimum supported Ruby version is 1.9.3.
23
+ The minimum supported Ruby version is 2.1. (You will need `rbenv` if your
24
+ os does not support Ruby >= 2.1, e.g. on Debian wheezy.)
23
25
 
24
26
  Installation
25
27
  ------------
@@ -77,8 +79,9 @@ Setting the seed ratio limit is supported per feed:
77
79
  feeds:
78
80
  - url: http://example.com/feed1
79
81
  seed_ratio_limit: 0
80
-
81
- Configurable certificate validation, good for self-signed certificates. Default is true:
82
+
83
+ Configurable certificate validation, good for self-signed certificates. Default
84
+ is true:
82
85
 
83
86
  feeds:
84
87
  - url: http://example.com/feed1
@@ -136,6 +139,9 @@ transmission is configured for HTTP basic authentication.
136
139
  user: nobody
137
140
  group: nobody
138
141
 
142
+ client:
143
+ timeout: 5
144
+
139
145
  fork: false
140
146
 
141
147
  pid_file: false
@@ -47,10 +47,6 @@ config = TransmissionRSS::Config.instance
47
47
  # Initialize a log instance and configure it.
48
48
  log = Log.instance
49
49
  log.target = config.log_target
50
- log.level = Logger::DEBUG
51
- log.formatter = proc do |sev, time, _, msg|
52
- "#{time.to_i}(#{sev.downcase}) #{msg}\n"
53
- end
54
50
 
55
51
  # Load config file (default or given by argument).
56
52
  begin
@@ -78,10 +78,6 @@ config = TransmissionRSS::Config.instance
78
78
  # Initialize a log instance and configure it.
79
79
  log = Log.instance
80
80
  log.target = config.log_target
81
- log.level = Logger::DEBUG
82
- log.formatter = proc do |sev, time, _, msg|
83
- "#{time.to_i}(#{sev.downcase}) #{msg}\n"
84
- end
85
81
 
86
82
  # Load config file (default or given by argument).
87
83
  begin
@@ -147,13 +143,13 @@ if reset_seen_file
147
143
  end
148
144
 
149
145
  # Initialize communication to transmission.
150
- client = Client.new(config.server, config.login)
146
+ client = Client.new(config.server, config.login, config.client)
151
147
 
152
148
  # Callback for a new item on one of the feeds.
153
149
  aggregator.on_new_item do |torrent_file, feed, download_path|
154
150
  client.add_torrent(torrent_file, :url,
155
151
  paused: config.add_paused,
156
- download_path: download_path,
152
+ download_dir: download_path,
157
153
  seed_ratio_limit: feed.config.seed_ratio_limit)
158
154
  end
159
155
 
@@ -7,10 +7,14 @@ require File.join(File.dirname(__FILE__), 'log')
7
7
  module TransmissionRSS
8
8
  # Class for communication with transmission utilizing the RPC web interface.
9
9
  class Client
10
+ OPTIONS = [:paused, :download_dir]
11
+
10
12
  class Unauthorized < StandardError
11
13
  end
12
14
 
13
15
  def initialize(server = {}, login = nil, options = {})
16
+ options ||= {}
17
+
14
18
  @host = server.host || 'localhost'
15
19
  @port = server.port || 9091
16
20
  @rpc_path = server.rpc_path || '/transmission/rpc'
@@ -39,10 +43,7 @@ module TransmissionRSS
39
43
 
40
44
  # POST json packed torrent add command.
41
45
  def add_torrent(file, type = :url, options = {})
42
- arguments = {
43
- 'paused' => options[:paused],
44
- 'download-dir' => options[:download_path]
45
- }
46
+ arguments = set_arguments_from_options(options)
46
47
 
47
48
  case type
48
49
  when :url
@@ -136,5 +137,17 @@ module TransmissionRSS
136
137
 
137
138
  raise
138
139
  end
140
+
141
+ def set_arguments_from_options(options)
142
+ arguments = {}
143
+
144
+ OPTIONS.each do |o|
145
+ unless options[o].nil?
146
+ arguments[o.to_s.sub('_', '-')] = options[o]
147
+ end
148
+ end
149
+
150
+ arguments
151
+ end
139
152
  end
140
153
  end
@@ -6,21 +6,30 @@ module TransmissionRSS
6
6
  class Log
7
7
  include Singleton
8
8
 
9
- # Change log target (IO or path to a file as String).
10
- def target=(target)
9
+ def initialize(target = $stderr)
11
10
  old_logger = @logger
12
- @logger = Logger.new target
11
+ @logger ||= Logger.new(target)
13
12
 
14
13
  if old_logger
15
14
  @logger.level = old_logger.level
16
15
  @logger.formatter = old_logger.formatter
16
+ else
17
+ @logger.level = Logger::DEBUG
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
17
22
  end
18
23
  end
19
24
 
25
+ # Change log target (IO or path to a file as String).
26
+ def target=(target)
27
+ initialize(target)
28
+ end
29
+
20
30
  # If this class misses a method, call it on the encapsulated Logger class.
21
31
  def method_missing(sym, *args)
22
- @logger ||= Logger.new $stderr
23
- @logger.send sym, *args
32
+ @logger.send(sym, *args)
24
33
  end
25
34
  end
26
35
  end
@@ -1,3 +1,3 @@
1
1
  module TransmissionRSS
2
- VERSION = '0.2.6'
2
+ VERSION = '1.0.0.alpha1'
3
3
  end
@@ -58,6 +58,11 @@ feeds:
58
58
  # user: nobody
59
59
  # group: nobody
60
60
 
61
+ # Other Transmission client options
62
+
63
+ #client:
64
+ # timeout: 5
65
+
61
66
  # Fork?
62
67
 
63
68
  #fork: false
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.2.6
4
+ version: 1.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - henning mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-04 00:00:00.000000000 Z
11
+ date: 2017-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open_uri_redirections
@@ -86,14 +86,14 @@ 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
- version: '0'
91
+ version: '2.1'
92
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - ">"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 1.3.1
97
97
  requirements: []
98
98
  rubyforge_project:
99
99
  rubygems_version: 2.6.13