feed_torrents 0.1.3 → 0.1.4

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: 0ed2414f8854da228660b43c25d22c1134429c11
4
- data.tar.gz: b5663aa4d7085fe93ff620886f632fb3c12dd9d5
3
+ metadata.gz: bc50206010bc05f26efcf229d0f4ab915f32c00b
4
+ data.tar.gz: 661b0b14bc061ecd58b0f103412d834188d79868
5
5
  SHA512:
6
- metadata.gz: 9154f89525b2c3a0a6ca4abb3a63e423f3410f33ecc0c476494967445dd343f319c273c5fcca4bef00efa36a694ae9db66e53e46447dc34686a79ade8c63518b
7
- data.tar.gz: 377b9ff8795349e26609dec3d837266616061c2bdb36536228f6e090c13e48c37bb39466b7236dd5e77cb8b403d97e03223bec84373e2e3f380c175c6b85bfb8
6
+ metadata.gz: ff9d49df34b3537f04ad383c04dc0d5685eb6ac2e0fb05eab52e94a2b59f84b47f00ec3eb2d5146dbbcdf467a25548229a02f32b268c202fa56349892f95fc7e
7
+ data.tar.gz: 15102d9be5ff4f5f81ae1159833a92433d2278d7fd9c766683f912b3928089f638bc7c954df94b04a2deac856f91ffed444aabe73cd0f7fb135f536eb180cd97
data/bin/feed_torrents CHANGED
@@ -15,11 +15,23 @@ end
15
15
 
16
16
  require 'feed_torrents'
17
17
 
18
+ FeedTorrents.configuration.filter_testing = true if ARGV.delete('--test-filters')
19
+
18
20
  if ARGV.length != 1
19
- puts "Usage: #{$0} <configfile>"
21
+ puts "Usage: #{$0} <configfile> [--test-filters]"
22
+ puts "Retrieves rss lists every interval and downloads new torrents from torrent or magnet links"
23
+ puts
24
+ puts " --test-filters Prints all matches to STDOUT and won't do anything else"
25
+ puts
26
+ puts "Report bugs at: https://github.com/TvL2386/feed_torrents/issues"
20
27
  exit 1
21
28
  else
22
29
  FeedTorrents.configuration.yaml_from_file ARGV[0]
23
30
  end
24
31
 
32
+ if FeedTorrents.configuration.filter_testing?
33
+ puts 'Filter testing enabled. Please press CTRL+C when you are done'.yellow.bold
34
+ puts
35
+ end
36
+
25
37
  FeedTorrents::Reactor.start!
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.add_dependency 'eventmachine', '~> 1.0'
19
19
  gem.add_dependency 'simple-rss', '~> 1.3'
20
20
  gem.add_dependency 'em-http-request', '~> 1.1'
21
+ gem.add_dependency 'term-ansicolor', '~> 1.3'
21
22
 
22
23
  gem.add_development_dependency 'bundler', '~> 1.5'
23
24
  gem.add_development_dependency 'rake', '~> 10.4'
data/lib/feed_torrents.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'term/ansicolor'
2
+ include Term::ANSIColor
3
+
1
4
  require 'feed_torrents/log_functions'
2
5
  require 'feed_torrents/configuration'
3
6
 
@@ -33,6 +33,14 @@ module FeedTorrents
33
33
  @source.send(method, *args, &block)
34
34
  end
35
35
 
36
+ def filter_testing=(value)
37
+ @filter_testing = !!value
38
+ end
39
+
40
+ def filter_testing?
41
+ @filter_testing
42
+ end
43
+
36
44
  private
37
45
 
38
46
  def source
@@ -40,7 +48,7 @@ module FeedTorrents
40
48
  end
41
49
 
42
50
  def create_logger
43
- if self.log and self.log[:out] == 'STDOUT'
51
+ if self.log && self.log[:out] == 'STDOUT' || filter_testing?
44
52
  obj = Logger.new(STDOUT)
45
53
  else
46
54
  obj = Logger.new(File.expand_path(self.log[:out]), self.log[:rotate], self.log[:size])
@@ -1,4 +1,5 @@
1
1
  require 'pathname'
2
+ require 'fileutils'
2
3
 
3
4
  module FeedTorrents
4
5
  module Feed
@@ -10,21 +11,25 @@ module FeedTorrents
10
11
  end
11
12
 
12
13
  def process
13
- info "Downloading torrent for '#{@title}' (#{torrent_link})"
14
- http = EM::HttpRequest.new(torrent_link, inactivity_timeout: @timeout).get
15
- fh = File.new(file,'wb')
16
-
17
- http.stream { |chunk| fh.write chunk }
18
-
19
- http.errback do
20
- error "failure retrieving torrent for '#{@title}' (#{torrent_link})"
21
- error "error: #{http.error}"
22
- end
23
-
24
- http.callback do
25
- info "Downloading torrent for #{@title} completed"
26
- fh.close
27
- FeedTorrents.store.persist(@link)
14
+ if FeedTorrents.configuration.filter_testing?
15
+ puts "Would have downloaded torrent for '#{@title}' (#{torrent_link})".bold.cyan
16
+ else
17
+ info "Downloading torrent for '#{@title}' (#{torrent_link})"
18
+ http = EM::HttpRequest.new(torrent_link, inactivity_timeout: @timeout).get
19
+ fh = File.new(file,'wb')
20
+
21
+ http.stream { |chunk| fh.write chunk }
22
+
23
+ http.errback do
24
+ error "failure retrieving torrent for '#{@title}' (#{torrent_link})"
25
+ error "error: #{http.error}"
26
+ end
27
+
28
+ http.callback do
29
+ info "Downloading torrent for #{@title} completed"
30
+ fh.close
31
+ FeedTorrents.store.persist(@link)
32
+ end
28
33
  end
29
34
  end
30
35
 
@@ -47,7 +52,9 @@ module FeedTorrents
47
52
  end
48
53
 
49
54
  def file
50
- Pathname.new(@directory).join("#{@title}.torrent").expand_path
55
+ dir = Pathname.new(@directory).expand_path
56
+ FileUtils.mkdir_p(dir) unless dir.exist?
57
+ dir.join("#{@title}.torrent")
51
58
  end
52
59
  end
53
60
  end
@@ -58,8 +58,13 @@ module FeedTorrents
58
58
 
59
59
  rss.items.each do |item|
60
60
  link = CGI.unescapeHTML(item.link)
61
- process(item.title, link) if !already_processed?(link) and matches_filter?(item.title)
61
+
62
+ if matches_filter?(item.title)
63
+ process(item.title, link) if FeedTorrents.configuration.filter_testing? || !already_processed?(link)
64
+ end
62
65
  end
66
+ rescue Exception => e
67
+ error "list #{@name} caused exception #{e.class}: #{e.message}"
63
68
  end
64
69
 
65
70
  def process(title, link)
@@ -1,3 +1,3 @@
1
1
  module FeedTorrents
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feed_torrents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom van Leeuwen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-11 00:00:00.000000000 Z
11
+ date: 2015-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: term-ansicolor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement