torrent_rss 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/bin/torrent_rss +5 -0
- data/lib/torrent_rss.rb +12 -0
- data/lib/torrent_rss/cli.rb +20 -0
- data/lib/torrent_rss/config.rb +31 -0
- data/lib/torrent_rss/entry_log.rb +40 -0
- data/lib/torrent_rss/feed.rb +27 -0
- data/lib/torrent_rss/torrent.rb +30 -0
- data/lib/torrent_rss/version.rb +3 -0
- data/spec/spec_helper.rb +3 -0
- data/torrent_rss.gemspec +28 -0
- metadata +175 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Andrew Nordman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# TorrentRSS
|
2
|
+
|
3
|
+
TorrentRSS is a command-line utility for downloading torrent files from an RSS feed, looking
|
4
|
+
for new entries by recording the ID of the RSS item in a log file (The entry ID is MD5'd in the event
|
5
|
+
that the ID is a URL).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'torrent_rss'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install torrent_rss
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
The primary command is `torrent_rss fetch`. The command takes an array of RSS feeds and parses them for
|
24
|
+
new entries to download to a specific folder. By default, it will look for a configuration file found at
|
25
|
+
`~/.torrent_rss`. This configuration file is written using [TOML](https://github.com/mojombo/toml), and
|
26
|
+
includes the destination directory and the array of RSS feeds to query.
|
27
|
+
|
28
|
+
TorrentRSS also supports command-line flags that override anything set in `~/.torrent_rss`. Options:
|
29
|
+
-f, [--feeds=one two three] # Array of Feed URLs to parse and download from
|
30
|
+
-d, [--directory=DIRECTORY] # Directory to download torrent files from
|
31
|
+
|
32
|
+
Downloaded items have their IDs MD5'd and logged in `~/.torrent_rss_log` to prevent redownloading.
|
33
|
+
|
34
|
+
Questions? Issues? Want to contribute? Pull requests and issues welcome.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/torrent_rss
ADDED
data/lib/torrent_rss.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "torrent_rss/version"
|
2
|
+
require 'torrent_rss/config'
|
3
|
+
require 'torrent_rss/entry_log'
|
4
|
+
require 'torrent_rss/torrent'
|
5
|
+
require 'torrent_rss/feed'
|
6
|
+
require 'torrent_rss/cli'
|
7
|
+
|
8
|
+
require 'feedzirra'
|
9
|
+
|
10
|
+
module TorrentRss
|
11
|
+
# Your code goes here...
|
12
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module TorrentRSS
|
4
|
+
class CLI < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
desc 'fetch', 'parses RSS feeds and downloads any new torrent files'
|
8
|
+
method_option :feeds, aliases: '-f', type: :array, desc: 'Array of Feed URLs to parse and download from'
|
9
|
+
method_option :directory, aliases: '-d', desc: 'Directory to download torrent files from'
|
10
|
+
def fetch
|
11
|
+
feed_urls = options[:feeds] || Config.feeds || []
|
12
|
+
directory = options[:directory] || Config.directory || '.'
|
13
|
+
|
14
|
+
feed_urls.each do |url|
|
15
|
+
feed = Feed.new url
|
16
|
+
feed.fetch! directory: directory
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'toml'
|
2
|
+
|
3
|
+
module TorrentRSS
|
4
|
+
class Config
|
5
|
+
class << self
|
6
|
+
def directory
|
7
|
+
config_data['directory']
|
8
|
+
end
|
9
|
+
|
10
|
+
def feeds
|
11
|
+
config_data['feeds']
|
12
|
+
end
|
13
|
+
|
14
|
+
def config_data
|
15
|
+
@config_data ||= read_config
|
16
|
+
end
|
17
|
+
|
18
|
+
def read_config
|
19
|
+
if File.exists? config_path
|
20
|
+
TOML.load_file config_path
|
21
|
+
else
|
22
|
+
{}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def config_path
|
27
|
+
File.expand_path "~/.torrent_rss"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'digest'
|
2
|
+
|
3
|
+
module TorrentRSS
|
4
|
+
class EntryLog
|
5
|
+
class << self
|
6
|
+
def has? entry_id
|
7
|
+
entries.include? encode_entry(entry_id)
|
8
|
+
end
|
9
|
+
|
10
|
+
def entries
|
11
|
+
@entries ||= read
|
12
|
+
end
|
13
|
+
|
14
|
+
def read
|
15
|
+
if File.exists? file_path
|
16
|
+
File.read(file_path).split("\n")
|
17
|
+
else
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def encode_entry entry_id
|
23
|
+
Digest::MD5.hexdigest entry_id
|
24
|
+
end
|
25
|
+
|
26
|
+
def add entry_id
|
27
|
+
entries << encode_entry(entry_id)
|
28
|
+
save
|
29
|
+
end
|
30
|
+
|
31
|
+
def save
|
32
|
+
File.write file_path, entries.join("\n")
|
33
|
+
end
|
34
|
+
|
35
|
+
def file_path
|
36
|
+
File.expand_path("~/.torrent_rss_log")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module TorrentRSS
|
2
|
+
class Feed
|
3
|
+
attr_reader :url
|
4
|
+
def initialize url
|
5
|
+
@url = url
|
6
|
+
end
|
7
|
+
|
8
|
+
def fetch! options = {}
|
9
|
+
@directory = options[:directory]
|
10
|
+
parsed_feed.entries.each do |entry|
|
11
|
+
if new_entry? entry
|
12
|
+
torrent = Torrent.from_entry entry
|
13
|
+
torrent.download @directory
|
14
|
+
EntryLog.add entry.entry_id
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def new_entry? entry
|
20
|
+
!EntryLog.has? entry.entry_id
|
21
|
+
end
|
22
|
+
|
23
|
+
def parsed_feed
|
24
|
+
@feed ||= Feedzirra::Feed.fetch_and_parse @url
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
module TorrentRSS
|
3
|
+
class Torrent
|
4
|
+
attr_accessor :id, :url, :title, :summary
|
5
|
+
def self.from_entry entry
|
6
|
+
torrent = new
|
7
|
+
|
8
|
+
[:id, :url, :title, :summary].each do |attr|
|
9
|
+
torrent.send "#{attr}=", entry.send("#{attr}")
|
10
|
+
end
|
11
|
+
|
12
|
+
torrent
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@connection = Faraday.new do |builder|
|
17
|
+
builder.adapter Faraday.default_adapter
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def download directory
|
22
|
+
response = @connection.get @url
|
23
|
+
if response.success?
|
24
|
+
filename = response.headers['content-disposition'].match(/filename=\"(.+)\"/)[1]
|
25
|
+
File.write "#{directory}/#{filename}", response.body
|
26
|
+
end
|
27
|
+
response.success?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/torrent_rss.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'torrent_rss/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "torrent_rss"
|
8
|
+
spec.version = TorrentRSS::VERSION
|
9
|
+
spec.authors = ["Andrew Nordman"]
|
10
|
+
spec.email = ["cadwallion@gmail.com"]
|
11
|
+
spec.description = %q{Manage parsing RSS files for torrents and downloading them}
|
12
|
+
spec.summary = %q{Torrent RSS manager.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'faraday'
|
22
|
+
spec.add_runtime_dependency 'toml'
|
23
|
+
spec.add_runtime_dependency 'thor'
|
24
|
+
spec.add_runtime_dependency 'feedzirra'
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: torrent_rss
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrew Nordman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: toml
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: thor
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: feedzirra
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: bundler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.3'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.3'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rake
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rspec
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: Manage parsing RSS files for torrents and downloading them
|
127
|
+
email:
|
128
|
+
- cadwallion@gmail.com
|
129
|
+
executables:
|
130
|
+
- torrent_rss
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- .gitignore
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- bin/torrent_rss
|
140
|
+
- lib/torrent_rss.rb
|
141
|
+
- lib/torrent_rss/cli.rb
|
142
|
+
- lib/torrent_rss/config.rb
|
143
|
+
- lib/torrent_rss/entry_log.rb
|
144
|
+
- lib/torrent_rss/feed.rb
|
145
|
+
- lib/torrent_rss/torrent.rb
|
146
|
+
- lib/torrent_rss/version.rb
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
- torrent_rss.gemspec
|
149
|
+
homepage: ''
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ! '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
none: false
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubyforge_project:
|
170
|
+
rubygems_version: 1.8.23
|
171
|
+
signing_key:
|
172
|
+
specification_version: 3
|
173
|
+
summary: Torrent RSS manager.
|
174
|
+
test_files:
|
175
|
+
- spec/spec_helper.rb
|