download_tv 2.6.6 → 2.6.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,8 +17,8 @@ describe DownloadTV::Downloader do
17
17
  describe 'when creating the object' do
18
18
  it 'can receive an optional configuration hash' do
19
19
  dl = DownloadTV::Downloader.new(auto: true, grabber: 'KAT', path: config_path)
20
- _(dl.config.content[:auto]).must_equal true
21
- _(dl.config.content[:grabber]).must_equal 'KAT'
20
+ _(dl.config[:auto]).must_equal true
21
+ _(dl.config[:grabber]).must_equal 'KAT'
22
22
  end
23
23
  end
24
24
 
@@ -57,7 +57,7 @@ describe DownloadTV::Downloader do
57
57
  date = dl.date_to_check_from(1)
58
58
 
59
59
  _(date).must_equal(Date.today - 1)
60
- _(dl.config.content[:date]).must_equal Date.today
60
+ _(dl.config[:date]).must_equal Date.today
61
61
  end
62
62
  end
63
63
 
@@ -96,12 +96,12 @@ describe DownloadTV::Downloader do
96
96
  t.expect(:get_links, [], [show])
97
97
  dl = DownloadTV::Downloader.new(auto: true, path: config_path, pending: ['show 11'])
98
98
  _(dl.get_link(t, show, save_pending: true)).must_be_nil
99
- _(dl.config.content[:pending]).must_equal ['show 11', show]
99
+ _(dl.config[:pending]).must_equal ['show 11', show]
100
100
 
101
101
  t.expect(:get_links, [], [show])
102
102
  dl = DownloadTV::Downloader.new(auto: false, path: config_path, pending: [])
103
103
  _(dl.get_link(t, show, save_pending: true)).must_be_nil
104
- _(dl.config.content[:pending]).must_include show
104
+ _(dl.config[:pending]).must_include show
105
105
 
106
106
  t.verify
107
107
  end
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.6.6
4
+ version: 2.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - guille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-21 00:00:00.000000000 Z
11
+ date: 2022-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,6 +118,7 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - ".github/workflows/ruby.yml"
120
120
  - ".gitignore"
121
+ - ".rspec"
121
122
  - ".travis.yml"
122
123
  - CHANGELOG.md
123
124
  - Gemfile
@@ -131,19 +132,22 @@ files:
131
132
  - lib/download_tv/downloader.rb
132
133
  - lib/download_tv/filterer.rb
133
134
  - lib/download_tv/grabbers/eztv.rb
134
- - lib/download_tv/grabbers/kat.rb
135
135
  - lib/download_tv/grabbers/torrentapi.rb
136
- - lib/download_tv/grabbers/torrentz2.rb
136
+ - lib/download_tv/grabbers/torrentz.rb
137
137
  - lib/download_tv/grabbers/tpb.rb
138
138
  - lib/download_tv/linkgrabber.rb
139
139
  - lib/download_tv/myepisodes.rb
140
140
  - lib/download_tv/torrent.rb
141
141
  - lib/download_tv/version.rb
142
- - test/config_test.rb
142
+ - spec/download_tv/configuration_spec.rb
143
+ - spec/download_tv/filterer_spec.rb
144
+ - spec/download_tv/linkgrabber_spec.rb
145
+ - spec/download_tv/myepisodes_spec.rb
146
+ - spec/download_tv/torrent_spec.rb
147
+ - spec/spec_helper.rb
143
148
  - test/downloader_test.rb
144
149
  - test/grabbers_test.rb
145
150
  - test/test_helper.rb
146
- - test/torrent_test.rb
147
151
  homepage: https://github.com/guille/download_tv
148
152
  licenses:
149
153
  - MIT
@@ -170,8 +174,6 @@ summary: DownloadTV is a tool that allows the user to find magnet links for tv s
170
174
  episodes. It accepts shows as arguments, from a file or it can integrate with your
171
175
  MyEpisodes account.
172
176
  test_files:
173
- - test/config_test.rb
174
177
  - test/downloader_test.rb
175
178
  - test/grabbers_test.rb
176
179
  - test/test_helper.rb
177
- - test/torrent_test.rb
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DownloadTV
4
- ##
5
- # KATcr.co grabber
6
- class KAT < LinkGrabber
7
- attr_reader :max_tries
8
-
9
- def initialize
10
- super('https://katcr.co/advanced-usearch/')
11
- @max_tries = 5
12
- end
13
-
14
- def get_links(show)
15
- tries = 0
16
-
17
- params = {
18
- 'category': 'TV',
19
- 'orderby': 'seeds-desc',
20
- 'search': show
21
- }
22
-
23
- data = @agent.post(@url, params)
24
- .search('tbody tr td[1]')
25
-
26
- names = data.map do |i|
27
- i.search('a.torrents_table__torrent_title b')
28
- .text
29
- end
30
-
31
- links = data.map do |i|
32
- i.search('div.torrents_table__actions a[3]')
33
- .first
34
- .attribute('href')
35
- .text
36
- end
37
-
38
- raise NoTorrentsError if data.empty?
39
-
40
- names.zip(links)
41
- rescue Net::HTTP::Persistent::Error => e
42
- raise unless e.message =~ /too many connection resets/
43
- raise if tries >= @max_tries
44
-
45
- tries += 1
46
- retry
47
- end
48
- end
49
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DownloadTV
4
- ##
5
- # EZTV.ag grabber
6
- class Torrentz < LinkGrabber
7
- def initialize
8
- super('https://torrentzeu.org/kick.php?q=%s')
9
- end
10
-
11
- def get_links(show)
12
- raw_data = @agent.get(format(@url, show))
13
- results = raw_data.search('tbody tr')
14
-
15
- # require 'byebug'; byebug
16
-
17
- raise NoTorrentsError if results.empty?
18
-
19
- data = results.sort_by { |e| e.search('td[data-title="Last Updated"]')[1].text.to_i }.reverse
20
-
21
- data.collect do |i|
22
- [i.children[1].text.strip,
23
- i.children[11].children[1].attribute('href').text]
24
- end
25
- end
26
- end
27
- end
data/test/config_test.rb DELETED
@@ -1,175 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- describe DownloadTV::Configuration do
6
- config_path = File.realdirpath("#{__dir__}/test_config")
7
-
8
- before do
9
- Dir.chdir(__dir__)
10
- end
11
-
12
- after do
13
- File.delete(config_path) if File.exist?(config_path)
14
- end
15
-
16
- describe 'when the file already exists' do
17
- it 'will load the existing configuration (blank)' do
18
- create_dummy_config(config_path)
19
-
20
- c = DownloadTV::Configuration.new(path: config_path)
21
- _(c.content).must_equal(path: config_path, version: DownloadTV::VERSION)
22
- end
23
-
24
- it 'will load the existing configuration (existing)' do
25
- create_dummy_config(config_path, auto: false, myepisodes_user: 'dummy')
26
-
27
- c = DownloadTV::Configuration.new(path: config_path)
28
- _(c.content).must_equal(path: config_path, auto: false, myepisodes_user: 'dummy', version: DownloadTV::VERSION)
29
- end
30
-
31
- it 'will get overwritten by the parameters given' do
32
- create_dummy_config(config_path, myepisodes_user: 'dummy')
33
-
34
- c = DownloadTV::Configuration.new(path: config_path, myepisodes_user: 'fake')
35
- _(c.content).must_equal(path: config_path, myepisodes_user: 'fake', version: DownloadTV::VERSION)
36
- end
37
-
38
- it 'will downcase ignored shows' do
39
- create_dummy_config(config_path, ignored: %w[duMMy String])
40
-
41
- c = DownloadTV::Configuration.new(path: config_path)
42
- _(c.content[:ignored]).must_equal %w[dummy string]
43
- end
44
- end
45
-
46
- describe 'the breaking_changes method' do
47
- it 'returns nil when both versions are equal' do
48
- create_dummy_config(config_path)
49
-
50
- c = DownloadTV::Configuration.new(path: config_path)
51
- _(c.breaking_changes?(DownloadTV::VERSION)).must_be_nil
52
- end
53
-
54
- it "returns true when there's been a major update" do
55
- create_dummy_config(config_path)
56
-
57
- split = DownloadTV::VERSION.split('.')
58
- split[0] = (split[0].to_i - 1).to_s
59
- new_version = split.join('.')
60
- c = DownloadTV::Configuration.new(path: config_path)
61
- _(c.breaking_changes?(new_version)).must_equal true
62
- end
63
-
64
- it "returns true when there's been a minor update" do
65
- create_dummy_config(config_path)
66
-
67
- split = DownloadTV::VERSION.split('.')
68
- split[1] = (split[1].to_i - 1).to_s
69
- new_version = split.join('.')
70
- c = DownloadTV::Configuration.new(path: config_path)
71
- _(c.breaking_changes?(new_version)).must_equal true
72
- end
73
-
74
- it "returns false when it's a small patch" do
75
- create_dummy_config(config_path)
76
-
77
- split = DownloadTV::VERSION.split('.')
78
- split[2] = (split[2].to_i - 1).to_s
79
- new_version = split.join('.')
80
- c = DownloadTV::Configuration.new(path: config_path)
81
- _(c.breaking_changes?(new_version)).must_equal false
82
- end
83
- end
84
-
85
- describe "when the file doesn't exist" do
86
- it 'will create a new one' do
87
- run_silently do
88
- STDIN.stub :gets, 'myepisodes\ncookie\nignored' do
89
- DownloadTV::Configuration.new(path: config_path)
90
- end
91
- end
92
-
93
- _(File.exist?(config_path)).must_equal true
94
- end
95
-
96
- it 'will have the right values' do
97
- c = nil
98
- run_silently do
99
- STDIN.stub :gets, 'anything' do
100
- c = DownloadTV::Configuration.new(path: config_path)
101
- end
102
- end
103
-
104
- _(c.content[:myepisodes_user]).must_equal 'anything'
105
- _(c.content[:cookie]).must_equal true
106
- _(c.content[:ignored]).must_equal ['anything']
107
- _(c.content[:auto]).must_equal true
108
- _(c.content[:pending]).must_equal []
109
- _(c.content[:grabber]).must_equal 'TorrentAPI'
110
- _(c.content[:date]).must_equal(Date.today - 1)
111
- _(c.content[:version]).must_equal DownloadTV::VERSION
112
- end
113
-
114
- it 'will set the cookie value to false when explicitly told so' do
115
- c = nil
116
- run_silently do
117
- STDIN.stub :gets, 'n' do
118
- c = DownloadTV::Configuration.new(path: config_path)
119
- end
120
- end
121
-
122
- _(c.content[:cookie]).must_equal false
123
- end
124
-
125
- it 'will separate the ignored values by commas' do
126
- c = nil
127
- run_silently do
128
- STDIN.stub :gets, 'ignored1, itsgone, ignored 2' do
129
- c = DownloadTV::Configuration.new(path: config_path)
130
- end
131
- end
132
- _(c.content[:ignored]).must_equal ['ignored1', 'itsgone', 'ignored 2']
133
- end
134
- end
135
-
136
- describe 'the serialize method' do
137
- it 'stores the configuration in a JSON file' do
138
- # Calls serialize
139
- run_silently do
140
- STDIN.stub :gets, 'anything' do
141
- DownloadTV::Configuration.new(path: config_path)
142
- end
143
- end
144
- # content = File.open(config_path, 'rb') { |f| Marshal.load(f) }
145
- source = File.read(config_path)
146
- content = JSON.parse(source, symbolize_names: true)
147
- content[:date] = Date.parse(content[:date])
148
-
149
- _(content[:cookie]).must_equal true
150
- _(content[:myepisodes_user]).must_equal 'anything'
151
- _(content[:ignored]).must_equal ['anything']
152
- _(content[:auto]).must_equal true
153
- _(content[:pending]).must_equal []
154
- _(content[:grabber]).must_equal 'TorrentAPI'
155
- _(content[:date]).must_equal Date.today - 1
156
- _(content[:version]).must_equal DownloadTV::VERSION
157
- end
158
- end
159
-
160
- describe 'the constructor' do
161
- it 'will trigger a configuration change when asked to' do
162
- create_dummy_config(config_path, auto: false)
163
- _(File.exist?(config_path)).must_equal true
164
- c = nil
165
-
166
- run_silently do
167
- STDIN.stub :gets, 'anything' do
168
- c = DownloadTV::Configuration.new(path: config_path)
169
- end
170
- end
171
-
172
- _(c.content[:auto]).must_equal false
173
- end
174
- end
175
- end
data/test/torrent_test.rb DELETED
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- describe DownloadTV::Torrent do
6
- grabber_names = DownloadTV::Torrent.new(nil).grabbers
7
- describe 'when creating the object' do
8
- before do
9
- @t = DownloadTV::Torrent.new
10
- end
11
-
12
- it 'will populate the instances' do
13
- _(@t.g_instances.size).must_equal grabber_names.size
14
- end
15
-
16
- it 'will start with all tries available' do
17
- _(@t.tries).must_equal grabber_names.size - 1
18
- end
19
-
20
- it 'will call get_links on its grabber' do
21
- @t.g_instances.first.stub :get_links, %w[test result] do
22
- _(@t.get_links('test show')).must_equal %w[test result]
23
- end
24
- end
25
- end
26
-
27
- describe 'when giving it a default grabber' do
28
- it 'has a default order' do
29
- t = DownloadTV::Torrent.new(nil)
30
- expected = grabber_names.map { |i| "DownloadTV::#{i}" }
31
- _(t.g_instances.map { |i| i.class.name }).must_equal expected
32
- end
33
-
34
- grabber_names.each do |g|
35
- it 'correctly uses the given grabber first' do
36
- t = DownloadTV::Torrent.new(g)
37
- _(t.g_instances.first.class.name).must_equal "DownloadTV::#{g}"
38
- end
39
- end
40
- end
41
- end