pirate-autonzb 0.2.2
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.
- data/Manifest +10 -0
- data/README.markdown +58 -0
- data/Rakefile +16 -0
- data/autonzb.gemspec +48 -0
- data/bin/autonzb +43 -0
- data/lib/imdb.rb +60 -0
- data/lib/inspector.rb +102 -0
- data/lib/movie.rb +149 -0
- data/lib/nfo.rb +29 -0
- data/lib/nzb.rb +75 -0
- metadata +117 -0
data/Manifest
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# AutoNZB
|
2
|
+
|
3
|
+
Ruby tool to automatically download x264 HD nzb movies files from newzleech.com
|
4
|
+
Currently only english and french subtitles are supported, but it's super easy to add your own language.
|
5
|
+
|
6
|
+
## Install
|
7
|
+
|
8
|
+
sudo gem install pirate-autonzb --source http://gems.github.com
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
In your terminal:
|
13
|
+
|
14
|
+
autonzb -d /path/of/download/nzb/directory
|
15
|
+
|
16
|
+
Will download new x264 HD movies nzb from newzleech.com, with imdb score >= 7.0, year >= 1950 and nzb age <= 160 days
|
17
|
+
|
18
|
+
autonzb -d /path/of/download/nzb/directory -movies /path/with/already/downloaded/movies -age 1 -imdb 7.5 -year 1980 -srt fr,en
|
19
|
+
|
20
|
+
Will download only new nzb of the day with imdb score >= 7.5, year >= 1980 and subtitles french or english.
|
21
|
+
The -movies setting prevents already owned movies to be re-downloaded (only if the owned movie is 'better' than the new release)
|
22
|
+
|
23
|
+
more details with:
|
24
|
+
|
25
|
+
autonzb -h
|
26
|
+
|
27
|
+
## Folder Name Convention
|
28
|
+
|
29
|
+
AutoNZB use (and needs) specific folders name for your movies:
|
30
|
+
|
31
|
+
name of the movie (year) tag(s) format source sound encoding lang [srt(s)]
|
32
|
+
|
33
|
+
Burn After Reading (2008) PROPER 1080p BluRay DTS x264 [fr,en]
|
34
|
+
Le Fabuleux Destin d'Amelie Poulain (2001) 720p BluRay x264 FRENCH [en]
|
35
|
+
...
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
Copyright (c) 2008 Pirate
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
42
|
+
a copy of this software and associated documentation files (the
|
43
|
+
"Software"), to deal in the Software without restriction, including
|
44
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
45
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
46
|
+
permit persons to whom the Software is furnished to do so, subject to
|
47
|
+
the following conditions:
|
48
|
+
|
49
|
+
The above copyright notice and this permission notice shall be
|
50
|
+
included in all copies or substantial portions of the Software.
|
51
|
+
|
52
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
55
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
56
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
57
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
58
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Rakefile
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'echoe'
|
5
|
+
|
6
|
+
Echoe.new('autonzb', '0.2.2') do |p|
|
7
|
+
p.description = "Ruby tool to automatically download x264 HD nzb movies files from newzleech.com"
|
8
|
+
p.url = "http://github.com/pirate/autonzb"
|
9
|
+
p.author = "Pirate"
|
10
|
+
p.email = "pirate.2061@gmail.com"
|
11
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
12
|
+
p.executable_pattern = "bin/autonzb"
|
13
|
+
p.runtime_dependencies = ["hpricot", "optiflag", 'rubyzip', 'htmlentities']
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/autonzb.gemspec
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{autonzb}
|
5
|
+
s.version = "0.2.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Pirate"]
|
9
|
+
s.date = %q{2008-12-24}
|
10
|
+
s.default_executable = %q{autonzb}
|
11
|
+
s.description = %q{Ruby tool to automatically download x264 HD nzb movies files from newzleech.com}
|
12
|
+
s.email = %q{pirate.2061@gmail.com}
|
13
|
+
s.executables = ["autonzb"]
|
14
|
+
s.extra_rdoc_files = ["bin/autonzb", "lib/imdb.rb", "lib/inspector.rb", "lib/movie.rb", "lib/nfo.rb", "lib/nzb.rb", "README.markdown"]
|
15
|
+
s.files = ["autonzb.gemspec", "bin/autonzb", "lib/imdb.rb", "lib/inspector.rb", "lib/movie.rb", "lib/nfo.rb", "lib/nzb.rb", "Manifest", "Rakefile", "README.markdown"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://github.com/pirate/autonzb}
|
18
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Autonzb", "--main", "README.markdown"]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubyforge_project = %q{autonzb}
|
21
|
+
s.rubygems_version = %q{1.3.1}
|
22
|
+
s.summary = %q{Ruby tool to automatically download x264 HD nzb movies files from newzleech.com}
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
+
s.specification_version = 2
|
27
|
+
|
28
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
+
s.add_runtime_dependency(%q<hpricot>, [">= 0"])
|
30
|
+
s.add_runtime_dependency(%q<optiflag>, [">= 0"])
|
31
|
+
s.add_runtime_dependency(%q<rubyzip>, [">= 0"])
|
32
|
+
s.add_runtime_dependency(%q<htmlentities>, [">= 0"])
|
33
|
+
s.add_development_dependency(%q<echoe>, [">= 0"])
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<hpricot>, [">= 0"])
|
36
|
+
s.add_dependency(%q<optiflag>, [">= 0"])
|
37
|
+
s.add_dependency(%q<rubyzip>, [">= 0"])
|
38
|
+
s.add_dependency(%q<htmlentities>, [">= 0"])
|
39
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
40
|
+
end
|
41
|
+
else
|
42
|
+
s.add_dependency(%q<hpricot>, [">= 0"])
|
43
|
+
s.add_dependency(%q<optiflag>, [">= 0"])
|
44
|
+
s.add_dependency(%q<rubyzip>, [">= 0"])
|
45
|
+
s.add_dependency(%q<htmlentities>, [">= 0"])
|
46
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
47
|
+
end
|
48
|
+
end
|
data/bin/autonzb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optiflag'
|
4
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'inspector')
|
5
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'nzb')
|
6
|
+
|
7
|
+
module AutoNZB extend OptiFlagSet
|
8
|
+
flag "d" do
|
9
|
+
description "Download directory path for new nzb"
|
10
|
+
end
|
11
|
+
optional_flag "movies" do
|
12
|
+
description "Directories paths (separated by ,) with all your Movie's folders"
|
13
|
+
end
|
14
|
+
optional_flag 'srt' do
|
15
|
+
description "Subtitle's language wanted (separated by ,), ie 'fr,en'.
|
16
|
+
Use 'none' if you want download movies without subtitle too.
|
17
|
+
(Order is important to define if a nzb is needed), default: none"
|
18
|
+
value_in_set ['fr', 'en', 'none']
|
19
|
+
end
|
20
|
+
optional_flag 'imdb' do
|
21
|
+
description "IMDB score limit, default: 7.0"
|
22
|
+
end
|
23
|
+
optional_flag 'year' do
|
24
|
+
description "Movie year limit, default: 1950"
|
25
|
+
value_matches ["year must be a year, like 1997", /[0-9]{4}/]
|
26
|
+
end
|
27
|
+
optional_flag 'age' do
|
28
|
+
description "Age limit, in day, of nbz file on newzleech, default: 160"
|
29
|
+
value_matches ["age must be a number", /[0-9]+/]
|
30
|
+
end
|
31
|
+
optional_flag "page" do
|
32
|
+
description "number of the page on newzleech, default: 1. Think to augment -a when change page number"
|
33
|
+
value_matches ["page must be a number", /[0-9]+/]
|
34
|
+
end
|
35
|
+
|
36
|
+
and_process!
|
37
|
+
end
|
38
|
+
|
39
|
+
inspector = Inspector.new(ARGV.flags.movies || '', :year => ARGV.flags.year,
|
40
|
+
:imdb_score => ARGV.flags.imdb,
|
41
|
+
:srt => ARGV.flags.srt)
|
42
|
+
|
43
|
+
nzbmatrix = NZB.new(inspector, ARGV.flags.d, :age => ARGV.flags.age, :page => ARGV.flags.page)
|
data/lib/imdb.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'hpricot'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'htmlentities'
|
5
|
+
|
6
|
+
class IMDB
|
7
|
+
|
8
|
+
attr_accessor :link
|
9
|
+
|
10
|
+
def initialize(name, year = nil, link = nil)
|
11
|
+
@name, @year, @link = name, year, link
|
12
|
+
@coder = HTMLEntities.new
|
13
|
+
set_doc
|
14
|
+
end
|
15
|
+
|
16
|
+
def score
|
17
|
+
if @doc && score_text = @doc.search("div.meta b").first
|
18
|
+
score_text.inner_html.match(/(.*)\/10/)[1].to_f
|
19
|
+
else
|
20
|
+
0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def year
|
25
|
+
@doc ? @doc.search("title").inner_html.match(/\s\(([0-9]{4})/)[1].to_i : @year.to_i
|
26
|
+
end
|
27
|
+
|
28
|
+
def name
|
29
|
+
$KCODE = 'utf-8'
|
30
|
+
@doc ? @coder.decode(@doc.search("title").inner_html.match(/(.*)\s\(/u)[1]) : @name
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def set_doc
|
36
|
+
if link
|
37
|
+
@doc = Hpricot(open(link))
|
38
|
+
else
|
39
|
+
query = "#{@name} (#{@year})"
|
40
|
+
search_url = "http://www.imdb.com/find?q=#{CGI::escape(query)}"
|
41
|
+
doc = Hpricot(open(search_url))
|
42
|
+
case doc.search("title").inner_html
|
43
|
+
when "IMDb Title Search" # search result page
|
44
|
+
if !doc.search("b[text()*='Media from'] a").empty?
|
45
|
+
imdb_id = doc.search("b[text()*='Media from'] a").first[:href]
|
46
|
+
movie_url = "http://www.imdb.com#{imdb_id}"
|
47
|
+
elsif !doc.search("td[@valign='top'] a[@href^='/title/tt']").empty?
|
48
|
+
imdb_id = doc.search("td[@valign='top'] a[@href^='/title/tt']").first[:href]
|
49
|
+
movie_url = "http://www.imdb.com#{imdb_id}"
|
50
|
+
end
|
51
|
+
@doc = Hpricot(open(movie_url))
|
52
|
+
when "IMDb Search"
|
53
|
+
@doc = nil
|
54
|
+
else # direct in movie page
|
55
|
+
@doc = doc
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/lib/inspector.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'movie')
|
2
|
+
|
3
|
+
class Inspector
|
4
|
+
|
5
|
+
def initialize(paths, options = {})
|
6
|
+
@paths = paths.split(',').map { |p| p.gsub!(/\/$/,'') }
|
7
|
+
@options = options
|
8
|
+
@options[:srt] = @options[:srt] ? @options[:srt].split(',') : ['none']
|
9
|
+
@options[:imdb_score] = @options[:imdb_score] ? @options[:imdb_score].to_f : 7.0
|
10
|
+
@options[:year] = @options[:year] ? @options[:year].to_i : 1950
|
11
|
+
|
12
|
+
@movies = []
|
13
|
+
initialize_movies
|
14
|
+
|
15
|
+
$stdout.print "Movie criteria: imdb_score >= #{@options[:imdb_score]}, year >= #{@options[:year]} and srt [#{@options[:srt].join(',')}]\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
def need?(movie)
|
19
|
+
if valid?(movie)
|
20
|
+
$stdout.print " => movie has required criteria "
|
21
|
+
if m = @movies.detect { |m| m == movie }
|
22
|
+
$stdout.print "but is already owned "
|
23
|
+
if srt_score(movie) > srt_score(m)
|
24
|
+
$stdout.print "but new movie has better subtitle: [#{movie.srt.join(',')}]\n"
|
25
|
+
true
|
26
|
+
elsif srt_score(movie) == srt_score(m)
|
27
|
+
if format_score(movie) > format_score(m)
|
28
|
+
$stdout.print "but new movie has better format: #{movie.format}\n"
|
29
|
+
true
|
30
|
+
elsif format_score(movie) == format_score(m)
|
31
|
+
if sound_score(movie) > sound_score(m)
|
32
|
+
$stdout.print "but new movie has better sound: #{movie.sound}\n"
|
33
|
+
true
|
34
|
+
else
|
35
|
+
$stdout.print "with same srt, format and sound\n"
|
36
|
+
false
|
37
|
+
end
|
38
|
+
else
|
39
|
+
$stdout.print "with same srt and better format: #{m.format}\n"
|
40
|
+
false
|
41
|
+
end
|
42
|
+
else
|
43
|
+
$stdout.print "with better subtitle: [#{m.srt.join(',')}]\n"
|
44
|
+
false
|
45
|
+
end
|
46
|
+
else
|
47
|
+
$stdout.print "and is not already owned\n"
|
48
|
+
true
|
49
|
+
end
|
50
|
+
else
|
51
|
+
$stdout.print " => movie doesn't have required criteria\n"
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def initialize_movies
|
60
|
+
@paths.each do |path|
|
61
|
+
old_movies_size = @movies.size
|
62
|
+
base_dir = clean_dir(Dir.new(path))
|
63
|
+
base_dir.each do |movie|
|
64
|
+
movie_path = "#{path}/#{movie}"
|
65
|
+
@movies << Movie.new(movie) if File.directory?(movie_path)
|
66
|
+
end
|
67
|
+
$stdout.print "Inspected #{@movies.size - old_movies_size} movie(s) in #{path}\n"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def clean_dir(dir)
|
72
|
+
dir.select { |e| !["..", ".", ".DS_Store"].include?(e) }
|
73
|
+
end
|
74
|
+
|
75
|
+
def valid?(movie)
|
76
|
+
srt_size = @options[:srt].size
|
77
|
+
(((@options[:srt] - movie.srt).size < srt_size) || @options[:srt].include?('none')) &&
|
78
|
+
movie.year >= @options[:year] && movie.score >= @options[:imdb_score]
|
79
|
+
end
|
80
|
+
|
81
|
+
def srt_score(movie)
|
82
|
+
srts = @options[:srt].reverse
|
83
|
+
movie.srt.inject(-1) do |score, srt|
|
84
|
+
s = (i = srts.index(srt)) ? i : -1
|
85
|
+
score = s if s > score
|
86
|
+
score
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def format_score(movie)
|
91
|
+
case movie.format
|
92
|
+
when '1080p'; 2
|
93
|
+
when '720p'; 1
|
94
|
+
else; 0
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def sound_score(movie)
|
99
|
+
movie.format == 'DTS' ? 1 : 0
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
data/lib/movie.rb
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'imdb')
|
2
|
+
require File.join(File.dirname(__FILE__), 'nfo')
|
3
|
+
|
4
|
+
class Movie
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
attr_accessor :path, :name, :format, :source, :sound, :encoding, :year, :srt, :lang, :score, :tags, :age,
|
8
|
+
:imdb_link, :nfo_link, :nzb_link
|
9
|
+
|
10
|
+
def initialize(raw_name, attributes = {})
|
11
|
+
@raw_name = raw_name.gsub(/\.|\_/,' ')
|
12
|
+
attributes.each { |k,v| send("#{k}=", v) }
|
13
|
+
@srt, @tags = [], []
|
14
|
+
|
15
|
+
set_imdb_link
|
16
|
+
set_name
|
17
|
+
set_format
|
18
|
+
set_source
|
19
|
+
set_sound
|
20
|
+
set_srt
|
21
|
+
set_lang
|
22
|
+
set_encoding
|
23
|
+
set_tags
|
24
|
+
set_year
|
25
|
+
end
|
26
|
+
|
27
|
+
def score
|
28
|
+
@score ||= imdb.score
|
29
|
+
end
|
30
|
+
|
31
|
+
def dirname
|
32
|
+
"#{name} (#{year}) #{tags.join(' ')} #{format} #{source} #{sound} #{encoding} #{lang} [#{srt.join(',')}]".gsub(/\s+/,' ')
|
33
|
+
end
|
34
|
+
|
35
|
+
def <=>(other_movie)
|
36
|
+
"#{name} #{year}".downcase <=> "#{other_movie.name} #{other_movie.year}".downcase
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def imdb
|
42
|
+
@imdb ||= IMDB.new(name, year, imdb_link)
|
43
|
+
end
|
44
|
+
|
45
|
+
def nfo
|
46
|
+
@nfo ||= NFO.new(nfo_link)
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_imdb_link
|
50
|
+
@imdb_link = nfo.imdb_link if imdb_link.nil? && nfo_link
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_name
|
54
|
+
@name = imdb.name if imdb_link
|
55
|
+
if @name.nil?
|
56
|
+
raw_name = @raw_name.gsub(/\(|\)|\[|\]|\{|\}|\//, ' ')
|
57
|
+
if matched = raw_name.match(/(.*)[0-9]{4}[^p]/)
|
58
|
+
@name = matched[1]
|
59
|
+
elsif matched = raw_name.match(/(.*)[0-9]{3,4}p/)
|
60
|
+
@name = matched[1]
|
61
|
+
else
|
62
|
+
@name = ''
|
63
|
+
end
|
64
|
+
@name.gsub!(/REPACK|LIMITED|UNRATED|PROPER|REPOST|Directors\sCut/iu,'')
|
65
|
+
@name.gsub!(/^\s+|\s+$/u,'')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def set_year
|
70
|
+
@year = imdb.year if imdb_link
|
71
|
+
if (year.nil? || year == 0) && matched = @raw_name.match(/19[0-9]{2}|20[0-9]{2}/)
|
72
|
+
@year = matched[0].to_i
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def set_format
|
77
|
+
@format = case @raw_name
|
78
|
+
when /1080p/i
|
79
|
+
'1080p'
|
80
|
+
when /720p/i
|
81
|
+
'720p'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def set_encoding
|
86
|
+
@encoding = case @raw_name
|
87
|
+
when /x264/i
|
88
|
+
'x264'
|
89
|
+
when /VC1/i
|
90
|
+
'VC1'
|
91
|
+
when /PS3/i
|
92
|
+
'PS3'
|
93
|
+
when /divx/i
|
94
|
+
'DIVX'
|
95
|
+
when /xvid/i
|
96
|
+
'XVID'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def set_source
|
101
|
+
@source = case @raw_name
|
102
|
+
when /Blu\s?Ray|Blu-Ray|BDRip/i
|
103
|
+
'BluRay'
|
104
|
+
when /HDDVD/i
|
105
|
+
'HDDVD'
|
106
|
+
when /HDTV/i
|
107
|
+
'HDTV'
|
108
|
+
when /DVD/i
|
109
|
+
'DVD'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def set_sound
|
114
|
+
@sound = case @raw_name
|
115
|
+
when /DTS/i
|
116
|
+
'DTS'
|
117
|
+
when /AC3/i
|
118
|
+
'AC3'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def set_srt
|
123
|
+
if nfo_link
|
124
|
+
@srt = nfo.srt
|
125
|
+
elsif matched = @raw_name.match(/\[(.*)\]/)
|
126
|
+
matched[1].split(',').each { |srt| @srt << srt }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def set_lang
|
131
|
+
@lang = case @raw_name
|
132
|
+
when /FRENCH/
|
133
|
+
'FRENCH'
|
134
|
+
when /GERMAN/
|
135
|
+
'GERMAN'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def set_tags
|
140
|
+
@tags << 'REPACK' if @raw_name =~ /REPACK/i
|
141
|
+
@tags << 'LIMITED' if @raw_name =~ /LIMITED/i
|
142
|
+
@tags << 'UNRATED' if @raw_name =~ /UNRATED/i
|
143
|
+
@tags << 'PROPER' if @raw_name =~ /PROPER/i
|
144
|
+
@tags << 'REPOST' if @raw_name =~ /REPOST/i
|
145
|
+
@tags << 'OUTDATED' if @raw_name =~ /OUTDATED/i
|
146
|
+
@tags << 'Directors Cut' if @raw_name =~ /Directors\sCut/i
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
data/lib/nfo.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
class NFO
|
4
|
+
|
5
|
+
attr_accessor :srt, :imdb_link
|
6
|
+
|
7
|
+
def initialize(url)
|
8
|
+
@nfo = open(url).read
|
9
|
+
@srt = []
|
10
|
+
|
11
|
+
parse_nfo
|
12
|
+
@srt.uniq!
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def parse_nfo
|
18
|
+
@nfo.split(/\n/).each do |line|
|
19
|
+
case line
|
20
|
+
when /subtitle|sub/i
|
21
|
+
@srt << 'fr' if line =~ /fr|fre|french/i
|
22
|
+
@srt << 'en' if line =~ /en|eng|english/i
|
23
|
+
when /imdb\.com\/title\//
|
24
|
+
@imdb_link = (matched = line.match(/imdb.com\/title\/(tt[0-9]+)/)) && "http://imdb.com/title/#{matched[1]}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/nzb.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'hpricot'
|
3
|
+
require 'zip/zip'
|
4
|
+
|
5
|
+
require File.join(File.dirname(__FILE__), 'movie')
|
6
|
+
|
7
|
+
class NZB
|
8
|
+
|
9
|
+
URL = 'http://www.newzleech.com'
|
10
|
+
|
11
|
+
attr_accessor :movies, :agent
|
12
|
+
|
13
|
+
def initialize(inspector, download_path, options = {})
|
14
|
+
@options = options
|
15
|
+
@options[:age] ||= 160
|
16
|
+
@options[:page] ||= 1
|
17
|
+
|
18
|
+
@nzb_url = "#{URL}/?group=143&minage=&age=160&min=4000&max=max&q=&m=search&adv=1&offset=#{(@options[:page].to_i - 1) * 60}"
|
19
|
+
@movies = []
|
20
|
+
|
21
|
+
parse_newzleech
|
22
|
+
movies.each do |movie|
|
23
|
+
$stdout.print "#{movie.dirname}, imdb score: #{movie.score} age: #{movie.age.to_i} day(s)\n"
|
24
|
+
if inspector.need?(movie)
|
25
|
+
$stdout.print " => DOWNLOAD: #{movie.name} (#{movie.year})\n"
|
26
|
+
download_nzb(download_path, movie)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
$stdout.print "No nzb found, maybe change -age or -page setting\n" if @movies.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
def download_nzb(download_path, movie)
|
33
|
+
path = download_path.gsub(/\/$/,'') # removed / at the end
|
34
|
+
Tempfile.open("movie.nzb") do |tempfile|
|
35
|
+
tempfile.write(open(movie.nzb_link).read) # download the nzb
|
36
|
+
tempfile.close
|
37
|
+
File.move(tempfile.path, "#{path}/#{movie.dirname}.nzb")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def parse_newzleech
|
44
|
+
$stdout.print "Parsing #{URL} for new x264 HD nzb movies\n"
|
45
|
+
doc = Hpricot(open(@nzb_url))
|
46
|
+
doc.search("table.contentt").each do |table|
|
47
|
+
if (a = table.search("td.subject a[@href^='posts/?p=']").first) && a.inner_html !=~ /^\<img/
|
48
|
+
age = parse_age(table.search("td.age").first.inner_html) # get age of the nzb
|
49
|
+
if age <= @options[:age].to_f
|
50
|
+
raw_name = a.inner_html
|
51
|
+
nfo_link = (nfo = table.search("td.subject a[@href^='nfo.php?id=']").first) && "#{URL}/#{nfo[:href]}"
|
52
|
+
imdb_link = (imdb = table.search("td.subject a[@href^='http://anonym.to/?http://www.imdb.com']").first) && imdb[:href].match(/\?(.*)/)[1]
|
53
|
+
nzb_link = (nzb = table.search("td.get a[@href^='?m=gen&dl=1']").first) && "#{URL}/#{nzb[:href]}"
|
54
|
+
|
55
|
+
movie = Movie.new(raw_name, :nfo_link => nfo_link, :imdb_link => imdb_link, :nzb_link => nzb_link, :age => age)
|
56
|
+
@movies << movie
|
57
|
+
|
58
|
+
$stdout.print '.'
|
59
|
+
$stdout.flush
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
$stdout.print "\n"
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse_age(string)
|
67
|
+
case string
|
68
|
+
when /h/i
|
69
|
+
string.to_f / 24
|
70
|
+
when /d/i
|
71
|
+
string.to_f
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pirate-autonzb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pirate
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-24 00:00:00 -08:00
|
13
|
+
default_executable: autonzb
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hpricot
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: optiflag
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rubyzip
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: htmlentities
|
44
|
+
version_requirement:
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: echoe
|
53
|
+
version_requirement:
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
description: Ruby tool to automatically download x264 HD nzb movies files from newzleech.com
|
61
|
+
email: pirate.2061@gmail.com
|
62
|
+
executables:
|
63
|
+
- autonzb
|
64
|
+
extensions: []
|
65
|
+
|
66
|
+
extra_rdoc_files:
|
67
|
+
- bin/autonzb
|
68
|
+
- lib/imdb.rb
|
69
|
+
- lib/inspector.rb
|
70
|
+
- lib/movie.rb
|
71
|
+
- lib/nfo.rb
|
72
|
+
- lib/nzb.rb
|
73
|
+
- README.markdown
|
74
|
+
files:
|
75
|
+
- autonzb.gemspec
|
76
|
+
- bin/autonzb
|
77
|
+
- lib/imdb.rb
|
78
|
+
- lib/inspector.rb
|
79
|
+
- lib/movie.rb
|
80
|
+
- lib/nfo.rb
|
81
|
+
- lib/nzb.rb
|
82
|
+
- Manifest
|
83
|
+
- Rakefile
|
84
|
+
- README.markdown
|
85
|
+
has_rdoc: true
|
86
|
+
homepage: http://github.com/pirate/autonzb
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options:
|
89
|
+
- --line-numbers
|
90
|
+
- --inline-source
|
91
|
+
- --title
|
92
|
+
- Autonzb
|
93
|
+
- --main
|
94
|
+
- README.markdown
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: "1.2"
|
108
|
+
version:
|
109
|
+
requirements: []
|
110
|
+
|
111
|
+
rubyforge_project: autonzb
|
112
|
+
rubygems_version: 1.2.0
|
113
|
+
signing_key:
|
114
|
+
specification_version: 2
|
115
|
+
summary: Ruby tool to automatically download x264 HD nzb movies files from newzleech.com
|
116
|
+
test_files: []
|
117
|
+
|