transmission-rss 0.1.13 → 0.1.14

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
  SHA1:
3
- metadata.gz: a8eb08d11496d24bd539bd17237ea5aa523b362a
4
- data.tar.gz: 26f4c37a9e38353be0cf07dd3e58aa4f8e64a9be
3
+ metadata.gz: 920904c2e1205bfbfa74c6baacc111aa545c55d9
4
+ data.tar.gz: 1c3c0d44afa9284d4720b7226f9efefa91387427
5
5
  SHA512:
6
- metadata.gz: 6b26fdbcee2bf111a750a1aab971414e9c9ea28caea33a759c1e31b7bd7055a8048d5d710ed80d45f432a59ddf905f1647392cb6999c28f48994f8a89947da65
7
- data.tar.gz: 93196eb479cbcedd731f2db63aae7e5c1da222f31b9dcd28ee8ffee5b330acd501bb7304b101236b1885cbbcafc1768035fd3a6cab9c6bbd447111ee76acc73a
6
+ metadata.gz: efa71a1a7bca7c4a303380311d9611818cc63ea1b366f5489fb2bca248e4d2503141cae312645e268ae51d36674cdf7fcd000349cc27bef5721f4f617edb44fd
7
+ data.tar.gz: 6ea5f5a54e3120b4cd5ca03fa821c73cefc6f645fe51964783c036acdb86940b9235fb1ad29b16dee69f5ff393e513c15be4ca92e739d9cc60ead79ce1120267
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ transmission-rss
2
+ ================
3
+
4
+ transmission-rss is basically a workaround for transmission's lack of the
5
+ ability to monitor RSS feeds and automatically add enclosed torrent links.
6
+
7
+ It works with transmission-daemon and transmission-gtk (if the web frontend
8
+ is enabled in the settings dialog). Sites like showrss.karmorra.info and
9
+ ezrss.it or self-hosted seriesly instances are suited well as feed sources.
10
+
11
+ A tool called transmission-add-file is also included for mass adding of
12
+ torrent files.
13
+
14
+ As it's done with poems, I devote this very artful and romantic piece of
15
+ code to the single most delightful human being: Ann.
16
+
17
+ Installation
18
+ ------------
19
+
20
+ ### Latest stable version from rubygems.org
21
+
22
+ gem install transmission-rss
23
+
24
+ ### From source
25
+
26
+ git clone git://git.orgizm.net/transmission-rss.git
27
+ cd transmission-rss
28
+ gem build transmission-rss.gemspec
29
+ gem install transmission-rss-*.gem
30
+
31
+ Configuration
32
+ -------------
33
+
34
+ A yaml formatted config file is expected at `/etc/transmission-rss.conf`.
35
+
36
+ ### Minimal example
37
+
38
+ It should at least contain a list of feeds:
39
+
40
+ feeds:
41
+ - http://example.com/feed1
42
+ - http://example.com/feed2
43
+
44
+ ### All available options
45
+
46
+ The following configuration file example contains every existing option
47
+ (although `update_interval`, `add_paused` and `server` are default values
48
+ and could be omitted). The default `log_target` is STDERR. `privileges` is
49
+ not defined by default, so the script runs as current user/group.
50
+
51
+ feeds:
52
+ - http://example.com/feed1
53
+ - http://example.com/feed2
54
+
55
+ update_interval: 600
56
+
57
+ add_paused: false
58
+
59
+ server:
60
+ host: localhost
61
+ port: 9091
62
+
63
+ log_target: /var/log/transmissiond-rss.log
64
+
65
+ privileges:
66
+ user: nobody
67
+ group: nobody
68
+
69
+ fork: false
70
+
71
+ pid_file: false
72
+
73
+ TODO
74
+ ----
75
+
76
+ * Better library abilities.
77
+ * Option to stop seeding after full download.
78
+ * Configurable log level.
data/bin/transmission-rss CHANGED
@@ -131,7 +131,7 @@ aggregator.feeds.concat config.feeds
131
131
 
132
132
  # Callback for a new item on one of the feeds.
133
133
  aggregator.on_new_item do |torrent_file|
134
- Thread.start { client.add_torrent torrent_file, :url, config.add_paused }
134
+ client.add_torrent torrent_file, :url, config.add_paused
135
135
  end
136
136
 
137
137
  # Save PID.
@@ -1,7 +1,7 @@
1
1
  $:.unshift(File.dirname(__FILE__))
2
2
 
3
3
  module TransmissionRSS
4
- VERSION = '0.1.13'
4
+ VERSION = '0.1.14'
5
5
  end
6
6
 
7
7
  Dir.glob($:.first + '/**/*.rb').each do |lib|
@@ -67,10 +67,14 @@ class TransmissionRSS::Aggregator
67
67
 
68
68
  # The link is not in +@seen+ Array.
69
69
  unless seen? link
70
- on_new_item link
71
70
  @log.debug 'on_new_item event ' + link
72
-
73
- add_seen link
71
+ begin
72
+ on_new_item link
73
+ rescue Errno::ECONNREFUSED
74
+ # @log.debug 'not added to seenfile'
75
+ else
76
+ add_seen link
77
+ end
74
78
  end
75
79
  end
76
80
  end
@@ -1,49 +1,14 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
- require 'timeout'
4
3
  require 'base64'
5
4
 
6
- # TODO
7
- # * Why the hell do timeouts in get_session_id and add_torrent not work?!
8
-
9
5
  # Class for communication with transmission utilizing the RPC web interface.
10
6
  class TransmissionRSS::Client
11
- def initialize(host, port)
12
- @host = host
13
- @port = port
14
-
7
+ def initialize(host = 'localhost', port = 9091, timeout: 5)
8
+ @host, @port, @timeout = host, port, timeout
15
9
  @log = Log.instance
16
10
  end
17
11
 
18
- # Get transmission session id by simple GET.
19
- def get_session_id
20
- get = Net::HTTP::Get.new '/transmission/rpc'
21
-
22
- # retries = 3
23
- # begin
24
- # Timeout::timeout(5) do
25
- response = Net::HTTP.new(@host, @port).start do |http|
26
- http.request get
27
- end
28
- # end
29
- # rescue Timeout::Error
30
- # puts('timeout error exception') if($verbose)
31
- # if(retries > 0)
32
- # retries -= 1
33
- # puts('getSessionID timeout. retry..') if($verbose)
34
- # retry
35
- # else
36
- # $stderr << "timeout http://#{@host}:#{@port}/transmission/rpc"
37
- # end
38
- # end
39
-
40
- id = response.header['x-transmission-session-id']
41
-
42
- @log.debug 'got session id ' + id
43
-
44
- id
45
- end
46
-
47
12
  # POST json packed torrent add command.
48
13
  def add_torrent(file, type, paused = false)
49
14
  hash = {
@@ -57,7 +22,7 @@ class TransmissionRSS::Client
57
22
  when :url
58
23
  hash.arguments.filename = file
59
24
  when :file
60
- hash.arguments.metainfo = Base64.encode64 File.readlines(file).join
25
+ hash.arguments.metainfo = Base64.encode64(File.read(file))
61
26
  else
62
27
  raise ArgumentError.new 'type has to be :url or :file.'
63
28
  end
@@ -71,26 +36,38 @@ class TransmissionRSS::Client
71
36
 
72
37
  post.body = hash.to_json
73
38
 
74
- # retries = 3
75
- # begin
76
- # Timeout::timeout(5) do
77
- response = Net::HTTP.new(@host, @port).start do |http|
78
- http.request post
79
- end
80
- # end
81
- # rescue Timeout::Error
82
- # puts('timeout error exception') if($verbose)
83
- # if(retries > 0)
84
- # retries -= 1
85
- # puts('addTorrent timeout. retry..') if($verbose)
86
- # retry
87
- # else
88
- # $stderr << "timeout http://#{@host}:#{@port}/transmission/rpc"
89
- # end
90
- # end
39
+ response = request post
91
40
 
92
41
  result = JSON.parse(response.body).result
93
42
 
94
43
  @log.debug 'add_torrent result: ' + result
95
44
  end
45
+
46
+ # Get transmission session id.
47
+ def get_session_id
48
+ get = Net::HTTP::Get.new '/transmission/rpc'
49
+ response = request get
50
+
51
+ id = response.header['x-transmission-session-id']
52
+
53
+ @log.debug 'got session id ' + id
54
+
55
+ id
56
+ end
57
+
58
+ private
59
+
60
+ def request(data)
61
+ Timeout::timeout(@timeout) do
62
+ Net::HTTP.new(@host, @port).start do |http|
63
+ http.request data
64
+ end
65
+ end
66
+ rescue Errno::ECONNREFUSED
67
+ @log.debug 'connection refused'
68
+ raise
69
+ rescue Timeout::Error
70
+ @log.debug 'connection timeout'
71
+ raise
72
+ end
96
73
  end
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.13
4
+ version: 0.1.14
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-01-19 00:00:00.000000000 Z
11
+ date: 2014-03-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  transmission-rss is basically a workaround for
@@ -21,7 +21,7 @@ executables:
21
21
  extensions: []
22
22
  extra_rdoc_files: []
23
23
  files:
24
- - README.rdoc
24
+ - README.md
25
25
  - bin/transmission-add-file
26
26
  - bin/transmission-rss
27
27
  - lib/transmission-rss.rb
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  version: '0'
52
52
  requirements: []
53
53
  rubyforge_project:
54
- rubygems_version: 2.2.0
54
+ rubygems_version: 2.2.2
55
55
  signing_key:
56
56
  specification_version: 4
57
57
  summary: Adds torrents from rss feeds to transmission web frontend.
data/README.rdoc DELETED
@@ -1,79 +0,0 @@
1
- = transmission-rss
2
-
3
- transmission-rss is basically a workaround for transmission's lack of the
4
- ability to monitor RSS feeds and automatically add enclosed torrent links.
5
-
6
- It works with transmission-daemon and transmission-gtk (if the web frontend
7
- is enabled in the settings dialog). Sites like showrss.karmorra.info and
8
- ezrss.it are suited well as feed sources.
9
-
10
- For the GTK configuration editor, the Ruby libglade2 bindings are necessary
11
- (but not included in the gem dependencies). On Arch Linux, install
12
- ruby-libglade from AUR.
13
-
14
- A tool called transmission-add-file is also included for mass adding of
15
- torrent files.
16
-
17
- As it's done with poems, I devote this very artful and romantic piece of
18
- code to the single most delightful human being: Ann.
19
-
20
- == Installation
21
-
22
- === Latest stable version from rubygems.org
23
-
24
- gem install transmission-rss
25
-
26
- === From source
27
-
28
- git clone git://git.orgizm.net/transmission-rss.git
29
- cd transmission-rss
30
- gem build transmission-rss.gemspec
31
- gem install transmission-rss-*.gem
32
-
33
- == Configuration
34
-
35
- A yaml formatted config file is expected at +/etc/transmission-rss.conf+.
36
-
37
- === Minimal example
38
-
39
- It should at least contain a list of feeds:
40
-
41
- feeds:
42
- - http://example.com/feed1
43
- - http://example.com/feed2
44
-
45
- === All available options
46
-
47
- The following configuration file example contains every existing option
48
- (although +update_interval+, +add_paused+ and +server+ are default values
49
- and could be omitted). The default +log_target+ is STDERR. +privileges+ is
50
- not defined by default, so the script runs as current user/group.
51
-
52
- feeds:
53
- - http://example.com/feed1
54
- - http://example.com/feed2
55
-
56
- update_interval: 600
57
-
58
- add_paused: false
59
-
60
- server:
61
- host: localhost
62
- port: 9091
63
-
64
- log_target: /var/log/transmissiond-rss.log
65
-
66
- privileges:
67
- user: nobody
68
- group: nobody
69
-
70
- fork: false
71
-
72
- pid_file: false
73
-
74
- == TODO
75
-
76
- * Better library abilities.
77
- * Timeout and error handling in +Aggregator+ and +Client+.
78
- * Option to stop seeding after full download.
79
- * Configurable log level.