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 +4 -4
- data/bin/feed_torrents +13 -1
- data/feed_torrents.gemspec +1 -0
- data/lib/feed_torrents.rb +3 -0
- data/lib/feed_torrents/configuration.rb +9 -1
- data/lib/feed_torrents/feed/download.rb +23 -16
- data/lib/feed_torrents/feed/list.rb +6 -1
- data/lib/feed_torrents/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc50206010bc05f26efcf229d0f4ab915f32c00b
|
4
|
+
data.tar.gz: 661b0b14bc061ecd58b0f103412d834188d79868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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!
|
data/feed_torrents.gemspec
CHANGED
@@ -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
@@ -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
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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).
|
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
|
-
|
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)
|
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.
|
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
|
+
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
|