download_tv 2.0.6 → 2.1.0

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: e0609cdca28acf2d4f0800aaf0b0534532838940
4
- data.tar.gz: e1dcf35af5fd713796bf79d3281d44db5b14a45b
3
+ metadata.gz: 523099a5025846b793c54ead376345f8cb333012
4
+ data.tar.gz: 49e788cd21f2c40f3b4cc161c73a759cef1f873b
5
5
  SHA512:
6
- metadata.gz: 280c785035e34c5b05c05a00cca09a2ac84dcc20c70bdc8515ad1bfa98414cfbcd91406f1ac9a587ba013b0c97b4e301ae2375c9dcc71b3e5306125c14402150
7
- data.tar.gz: 1a82fccad76d549fd7afa47f51cb60a479aae2431b94cdf786f11adb880445814b142f812ceff21f975974dd6938114feb7e0c4f12a735d52c4c8e28d7e12d61
6
+ metadata.gz: 1a868b47c7d77f4b600bb487cbdb58553d7570920e8dd1b8a329d6d930744886cb5e8317f11e85c67cb42c6bd8f57327181d47e24af9c04f2d4e618496c9e4f5
7
+ data.tar.gz: d64ed3bebededda5d7c6da6b24265a88cd9bb049ed27ac829f5b4f53e172febaecf3d813b759817e543facd7358a7f9a1aea7e4d56a6edf64214731c494efa3b
data/bin/tv CHANGED
@@ -34,7 +34,7 @@ opt_parser = OptionParser.new do |opts|
34
34
  options[:cmd] = "config"
35
35
  end
36
36
 
37
- opts.on("--show-config", "Show current configuration values") do |n|
37
+ opts.on("--show-config", "Show current configuration values") do
38
38
  options[:cmd] = "showconfig"
39
39
  end
40
40
 
@@ -50,6 +50,20 @@ opt_parser = OptionParser.new do |opts|
50
50
  options[:subs] = n
51
51
  end
52
52
 
53
+ opts.on("-g", "--grabber GRABBER", "Use given grabber as first option") do |g|
54
+ options[:grabber] = g
55
+ end
56
+
57
+ opts.on("--show-grabbers", "List available grabbers") do
58
+ puts DownloadTV::Torrent.new.grabbers
59
+ exit
60
+ end
61
+
62
+ opts.on("-v", "Print version") do
63
+ puts DownloadTV::VERSION
64
+ exit
65
+ end
66
+
53
67
  opts.on_tail("-h", "--help", "Show this message") do
54
68
  puts opts
55
69
  exit
@@ -59,7 +73,7 @@ end
59
73
  opt_parser.parse!(ARGV)
60
74
 
61
75
  begin
62
- dl = DownloadTV::Downloader.new(options[:offset], options[:auto], options[:subs])
76
+ dl = DownloadTV::Downloader.new(options[:offset], options[:auto], options[:subs], options[:grabber])
63
77
  case options[:cmd]
64
78
  when "run"
65
79
  dl.run(options[:dry])
@@ -2,13 +2,14 @@ module DownloadTV
2
2
 
3
3
  class Downloader
4
4
 
5
- attr_reader :offset, :auto, :subs
5
+ attr_reader :offset, :auto, :subs, :grabber
6
6
  attr_accessor :config
7
7
 
8
- def initialize(offset, auto, subs, config={})
8
+ def initialize(offset, auto, subs, grabber, config={})
9
9
  @offset = offset.abs
10
10
  @auto = auto
11
11
  @subs = subs
12
+ @grabber = grabber
12
13
  if config.empty?
13
14
  @config = Configuration.new.content # Load configuration
14
15
  else
@@ -19,7 +20,7 @@ module DownloadTV
19
20
  end
20
21
 
21
22
  def download_single_show(show)
22
- t = Torrent.new
23
+ t = Torrent.new(@grabber)
23
24
  download(t.get_link(show, @auto))
24
25
  end
25
26
 
@@ -27,7 +28,7 @@ module DownloadTV
27
28
  def download_from_file(filename)
28
29
  filename = File.realpath(filename)
29
30
  raise "File doesn't exist" if !File.exists? filename
30
- t = Torrent.new
31
+ t = Torrent.new(@grabber)
31
32
  File.readlines(filename).each { |show| download(t.get_link(show, @auto)) }
32
33
 
33
34
  end
@@ -49,7 +50,7 @@ module DownloadTV
49
50
  puts "Nothing to download"
50
51
 
51
52
  else
52
- t = Torrent.new
53
+ t = Torrent.new(@grabber)
53
54
  to_download = fix_names(shows)
54
55
 
55
56
  queue = Queue.new
@@ -0,0 +1,34 @@
1
+ module DownloadTV
2
+ class KAT < LinkGrabber
3
+ def initialize
4
+ super('https://katcr.co/new/search-torrents.php?search="%s"&sort=seeders&order=desc')
5
+ end
6
+
7
+ def get_links(s)
8
+
9
+ # Format the url
10
+ search = @url % [s]
11
+
12
+ data = @agent.get(search).links.select {|i| i.href.include? "torrents-details.php?" }
13
+
14
+ raise NoTorrentsError if data == []
15
+
16
+ # Remove duplicates
17
+ data.keep_if { |i| i.text != "" }
18
+
19
+ names = data.collect &:text
20
+ links = []
21
+
22
+ data.each do |res|
23
+ page = res.click
24
+ links << page.search('a.kaGiantButton[title="Magnet link"]').attribute("href").text
25
+ end
26
+
27
+ names.zip(links)
28
+
29
+ end
30
+
31
+
32
+ end
33
+
34
+ end
@@ -4,12 +4,19 @@ module DownloadTV
4
4
 
5
5
  attr_reader :g_names, :g_instances, :n_grabbers
6
6
 
7
- def initialize
8
- @g_names = ["Eztv", "ThePirateBay", "TorrentAPI"]
7
+ def grabbers
8
+ ["Eztv", "KAT", "ThePirateBay", "TorrentAPI"]
9
+ end
10
+
11
+ def initialize(default_grabber=nil)
12
+ @g_names = grabbers
9
13
  @g_instances = Array.new
10
14
  @n_grabbers = @g_names.size # Initial size
11
15
  @tries = @n_grabbers - 1
12
16
 
17
+ # Silently ignores bad names
18
+ @g_names.rotate! @g_names.find_index(default_grabber).to_i
19
+
13
20
  @filters = [
14
21
  ->(n){n.include?("2160")},
15
22
  ->(n){n.include?("1080")},
@@ -1,3 +1,3 @@
1
1
  module DownloadTV
2
- VERSION = "2.0.6"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -7,38 +7,44 @@ describe DownloadTV::Downloader do
7
7
  end
8
8
 
9
9
  describe "when creating the object" do
10
- it "should receive three parameters" do
10
+ it "should receive four parameters" do
11
11
  ->{ DownloadTV::Downloader.new(0) }.must_raise ArgumentError
12
12
  ->{ DownloadTV::Downloader.new(0, true) }.must_raise ArgumentError
13
+ ->{ DownloadTV::Downloader.new(0, true, true) }.must_raise ArgumentError
13
14
  end
14
15
 
15
16
  it "can receive an optional configuration hash" do
16
- DownloadTV::Downloader.new(0, true, true, {:hi => 1}).config.must_equal ({:hi => 1})
17
+ DownloadTV::Downloader.new(0, true, true, nil, {:hi => 1}).config.must_equal ({:hi => 1})
17
18
  end
18
19
 
19
20
  it "should receive an integer for the offset" do
20
- ->{ DownloadTV::Downloader.new("foo", true, true, {1=>1}) }.must_raise NoMethodError
21
+ ->{ DownloadTV::Downloader.new("foo", true, true, nil, {1=>1}) }.must_raise NoMethodError
21
22
  end
22
23
 
23
24
  it "should store the first argument as @offset" do
24
- DownloadTV::Downloader.new(3, true, true, {1=>1}).offset.must_equal 3
25
+ DownloadTV::Downloader.new(3, true, true, nil, {1=>1}).offset.must_equal 3
25
26
  end
26
27
 
27
28
  it "should store the second argument as @auto" do
28
- DownloadTV::Downloader.new(3, true, true, {1=>1}).auto.must_equal true
29
- DownloadTV::Downloader.new(3, false, true, {1=>1}).auto.must_equal false
29
+ DownloadTV::Downloader.new(3, true, true, nil, {1=>1}).auto.must_equal true
30
+ DownloadTV::Downloader.new(3, false, true, nil, {1=>1}).auto.must_equal false
30
31
  end
31
32
 
32
- it "should store the second argument as @subs" do
33
- DownloadTV::Downloader.new(3, true, true, {1=>1}).subs.must_equal true
34
- DownloadTV::Downloader.new(3, true, false, {1=>1}).subs.must_equal false
33
+ it "should store the third argument as @subs" do
34
+ DownloadTV::Downloader.new(3, true, true, nil, {1=>1}).subs.must_equal true
35
+ DownloadTV::Downloader.new(3, true, false, nil, {1=>1}).subs.must_equal false
36
+ end
37
+
38
+ it "should store the fourth argument as @grabber" do
39
+ DownloadTV::Downloader.new(3, true, true, "KAT", {1=>1}).grabber.must_equal "KAT"
40
+ DownloadTV::Downloader.new(3, true, false, nil, {1=>1}).grabber.must_be_nil
35
41
  end
36
42
 
37
43
  end
38
44
 
39
45
  describe "the fix_names function" do
40
46
  config = {:ignored => ["Ignored"]}
41
- dl = DownloadTV::Downloader.new(0, true, true, config)
47
+ dl = DownloadTV::Downloader.new(0, true, true, nil, config)
42
48
 
43
49
  it "should remove apostrophes, colons and parens" do
44
50
  shows = ["Mr. Foo S01E02", "Bar (UK) S00E22", "Let's S05E03", "Baz: The Story S05E22"]
@@ -56,7 +62,7 @@ describe DownloadTV::Downloader do
56
62
 
57
63
 
58
64
  describe "the date file" do
59
- dl = DownloadTV::Downloader.new(0, true, true, {1=>1})
65
+ dl = DownloadTV::Downloader.new(0, true, true, nil, {1=>1})
60
66
 
61
67
  it "should be created if it doesn't exist" do
62
68
  dl.check_date
@@ -2,7 +2,7 @@ require "test_helper"
2
2
 
3
3
  describe DownloadTV::LinkGrabber do
4
4
 
5
- grabbers = ["Eztv", "ThePirateBay", "TorrentAPI"]
5
+ grabbers = DownloadTV::Torrent.new.grabbers
6
6
  instances = grabbers.map { |g| (DownloadTV.const_get g).new }
7
7
 
8
8
  instances.each do |grabber|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: download_tv
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - guille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-11 00:00:00.000000000 Z
11
+ date: 2017-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,6 +128,7 @@ files:
128
128
  - lib/download_tv/downloader.rb
129
129
  - lib/download_tv/grabbers/addic7ed.rb
130
130
  - lib/download_tv/grabbers/eztv.rb
131
+ - lib/download_tv/grabbers/kat.rb
131
132
  - lib/download_tv/grabbers/torrentapi.rb
132
133
  - lib/download_tv/grabbers/tpb.rb
133
134
  - lib/download_tv/linkgrabber.rb