download_tv 2.6.5 → 2.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/.rspec +1 -0
- data/CHANGELOG.md +17 -0
- data/Gemfile +2 -0
- data/README.md +9 -4
- data/bin/tv +9 -4
- data/lib/download_tv/configuration.rb +107 -81
- data/lib/download_tv/downloader.rb +21 -32
- data/lib/download_tv/filterer.rb +17 -17
- data/lib/download_tv/grabbers/eztv.rb +1 -1
- data/lib/download_tv/grabbers/torrentapi.rb +1 -1
- data/lib/download_tv/grabbers/torrentz.rb +25 -0
- data/lib/download_tv/grabbers/tpb.rb +1 -1
- data/lib/download_tv/linkgrabber.rb +6 -3
- data/lib/download_tv/myepisodes.rb +45 -38
- data/lib/download_tv/torrent.rb +37 -28
- data/lib/download_tv/version.rb +1 -1
- data/lib/download_tv.rb +0 -1
- data/spec/download_tv/configuration_spec.rb +199 -0
- data/spec/download_tv/filterer_spec.rb +107 -0
- data/spec/download_tv/linkgrabber_spec.rb +16 -0
- data/spec/download_tv/myepisodes_spec.rb +38 -0
- data/spec/download_tv/torrent_spec.rb +132 -0
- data/spec/spec_helper.rb +92 -0
- data/test/downloader_test.rb +5 -5
- metadata +11 -11
- data/lib/download_tv/grabbers/addic7ed.rb +0 -65
- data/lib/download_tv/grabbers/kat.rb +0 -49
- data/lib/download_tv/grabbers/torrentz2.rb +0 -27
- data/lib/download_tv/subtitles.rb +0 -17
- data/test/config_test.rb +0 -175
- data/test/torrent_test.rb +0 -41
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe DownloadTV::Torrent do
|
4
|
+
let(:default_grabber) { nil }
|
5
|
+
let(:eztv_mock) { double('eztv') }
|
6
|
+
let(:torrentapi_mock) { double('torrentapi') }
|
7
|
+
let(:torrentz_mock) { double('torrentz') }
|
8
|
+
let(:tpb_mock) { double('tpb') }
|
9
|
+
let(:test_show) { double('test_show') }
|
10
|
+
subject { described_class.new(default_grabber) }
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
allow(DownloadTV::TorrentAPI).to receive(:new).and_return torrentapi_mock
|
14
|
+
allow(DownloadTV::Torrentz).to receive(:new).and_return torrentz_mock
|
15
|
+
allow(DownloadTV::Eztv).to receive(:new).and_return eztv_mock
|
16
|
+
# allow(DownloadTV::ThePirateBay).to receive(:new).and_return tpb_mock
|
17
|
+
|
18
|
+
allow(torrentapi_mock).to receive(:online?).and_return(true)
|
19
|
+
allow(torrentz_mock).to receive(:online?).and_return(true)
|
20
|
+
allow(eztv_mock).to receive(:online?).and_return(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'Torrent.grabbers' do
|
24
|
+
it 'returns the list of grabbers' do
|
25
|
+
# This order is assumed in the other specs, so explicitly checking it here
|
26
|
+
expect(described_class.grabbers).to eq %w[TorrentAPI Torrentz Eztv]
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#get_links' do
|
32
|
+
it 'will use the first grabber and return its #get_link result' do
|
33
|
+
result = double('result')
|
34
|
+
expect(torrentapi_mock).to receive(:get_links).with(test_show).and_return(result)
|
35
|
+
|
36
|
+
result = subject.get_links(test_show)
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when the first grabber is offline' do
|
40
|
+
before do
|
41
|
+
allow(torrentapi_mock).to receive(:online?).and_return(false)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'will use the second grabber' do
|
45
|
+
expect(torrentapi_mock).not_to receive(:get_links)
|
46
|
+
expect(eztv_mock).not_to receive(:get_links)
|
47
|
+
expect(torrentz_mock).to receive(:get_links).with(test_show)
|
48
|
+
|
49
|
+
result = subject.get_links(test_show)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when all the grabbers are offline' do
|
54
|
+
before do
|
55
|
+
allow(torrentapi_mock).to receive(:online?).and_return(false)
|
56
|
+
allow(torrentz_mock).to receive(:online?).and_return(false)
|
57
|
+
allow(eztv_mock).to receive(:online?).and_return(false)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'will exit' do
|
61
|
+
expect(torrentapi_mock).not_to receive(:get_links)
|
62
|
+
expect(torrentz_mock).not_to receive(:get_links)
|
63
|
+
expect(eztv_mock).not_to receive(:get_links)
|
64
|
+
|
65
|
+
expect { subject.get_links(test_show) }.to raise_error(SystemExit)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when one grabber does not find a link' do
|
70
|
+
before do
|
71
|
+
allow(torrentapi_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
72
|
+
allow(torrentz_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'will keep trying until one does' do
|
76
|
+
expect(torrentapi_mock).to receive(:get_links).ordered
|
77
|
+
expect(torrentz_mock).to receive(:get_links).ordered
|
78
|
+
expect(eztv_mock).to receive(:get_links).ordered
|
79
|
+
|
80
|
+
result = subject.get_links(test_show)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when no grabber can find a link' do
|
85
|
+
before do
|
86
|
+
allow(torrentapi_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
87
|
+
allow(torrentz_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
88
|
+
allow(eztv_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'will return an empty array' do
|
92
|
+
expect(torrentapi_mock).to receive(:get_links).ordered
|
93
|
+
expect(torrentz_mock).to receive(:get_links).ordered
|
94
|
+
expect(eztv_mock).to receive(:get_links).ordered
|
95
|
+
|
96
|
+
expect(subject.get_links(test_show)).to eq []
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when the default grabber is set' do
|
101
|
+
let(:default_grabber) { 'Eztv' }
|
102
|
+
|
103
|
+
it 'will use that grabber preferently' do
|
104
|
+
test_show = double('test_show')
|
105
|
+
expect(torrentapi_mock).not_to receive(:get_links)
|
106
|
+
expect(torrentz_mock).not_to receive(:get_links)
|
107
|
+
expect(eztv_mock).to receive(:get_links).with(test_show)
|
108
|
+
|
109
|
+
result = subject.get_links(test_show)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when a grabber fails on a run and it is called twice' do
|
114
|
+
before do
|
115
|
+
count = 0
|
116
|
+
allow(torrentapi_mock).to receive(:get_links).exactly(2).times.with(test_show) do
|
117
|
+
count += 1
|
118
|
+
raise DownloadTV::NoTorrentsError if count == 1
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'the second run will use the original order' do
|
124
|
+
expect(torrentapi_mock).to receive(:get_links).exactly(2).times
|
125
|
+
expect(torrentz_mock).to receive(:get_links).exactly(1).time
|
126
|
+
|
127
|
+
result = subject.get_links(test_show)
|
128
|
+
result = subject.get_links(test_show)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
6
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
7
|
+
# files.
|
8
|
+
require 'download_tv'
|
9
|
+
#
|
10
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
11
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
12
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
13
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
14
|
+
# a separate helper file that requires the additional dependencies and performs
|
15
|
+
# the additional setup, and require it from the spec files that actually need
|
16
|
+
# it.
|
17
|
+
#
|
18
|
+
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
44
|
+
# have no way to turn it off -- the option exists only for backwards
|
45
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
46
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
47
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
48
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
49
|
+
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
52
|
+
# Allows RSpec to persist some state between runs in order to support
|
53
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
54
|
+
# you configure your source control system to ignore this file.
|
55
|
+
# config.example_status_persistence_file_path = "spec/examples.txt"
|
56
|
+
|
57
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
58
|
+
# recommended. For more details, see:
|
59
|
+
# https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode
|
60
|
+
# config.disable_monkey_patching!
|
61
|
+
|
62
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
63
|
+
# be too noisy due to issues in dependencies.
|
64
|
+
# config.warnings = true
|
65
|
+
|
66
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
67
|
+
# file, and it's useful to allow more verbose output when running an
|
68
|
+
# individual spec file.
|
69
|
+
# if config.files_to_run.one?
|
70
|
+
# Use the documentation formatter for detailed output,
|
71
|
+
# unless a formatter has already been configured
|
72
|
+
# (e.g. via a command-line flag).
|
73
|
+
# config.default_formatter = "doc"
|
74
|
+
# end
|
75
|
+
|
76
|
+
# Print the 10 slowest examples and example groups at the
|
77
|
+
# end of the spec run, to help surface which specs are running
|
78
|
+
# particularly slow.
|
79
|
+
# config.profile_examples = 10
|
80
|
+
|
81
|
+
# Run specs in random order to surface order dependencies. If you find an
|
82
|
+
# order dependency and want to debug it, you can fix the order by providing
|
83
|
+
# the seed, which is printed after each run.
|
84
|
+
# --seed 1234
|
85
|
+
# config.order = :random
|
86
|
+
|
87
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
88
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
89
|
+
# test failures related to randomization by passing the same `--seed` value
|
90
|
+
# as the one that triggered the failure.
|
91
|
+
# Kernel.srand config.seed
|
92
|
+
end
|
data/test/downloader_test.rb
CHANGED
@@ -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
|
21
|
-
_(dl.config
|
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
|
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
|
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
|
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.
|
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:
|
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
|
@@ -130,22 +131,23 @@ files:
|
|
130
131
|
- lib/download_tv/configuration.rb
|
131
132
|
- lib/download_tv/downloader.rb
|
132
133
|
- lib/download_tv/filterer.rb
|
133
|
-
- lib/download_tv/grabbers/addic7ed.rb
|
134
134
|
- lib/download_tv/grabbers/eztv.rb
|
135
|
-
- lib/download_tv/grabbers/kat.rb
|
136
135
|
- lib/download_tv/grabbers/torrentapi.rb
|
137
|
-
- lib/download_tv/grabbers/
|
136
|
+
- lib/download_tv/grabbers/torrentz.rb
|
138
137
|
- lib/download_tv/grabbers/tpb.rb
|
139
138
|
- lib/download_tv/linkgrabber.rb
|
140
139
|
- lib/download_tv/myepisodes.rb
|
141
|
-
- lib/download_tv/subtitles.rb
|
142
140
|
- lib/download_tv/torrent.rb
|
143
141
|
- lib/download_tv/version.rb
|
144
|
-
-
|
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
|
145
148
|
- test/downloader_test.rb
|
146
149
|
- test/grabbers_test.rb
|
147
150
|
- test/test_helper.rb
|
148
|
-
- test/torrent_test.rb
|
149
151
|
homepage: https://github.com/guille/download_tv
|
150
152
|
licenses:
|
151
153
|
- MIT
|
@@ -165,15 +167,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
167
|
- !ruby/object:Gem::Version
|
166
168
|
version: '0'
|
167
169
|
requirements: []
|
168
|
-
rubygems_version: 3.2.
|
170
|
+
rubygems_version: 3.2.30
|
169
171
|
signing_key:
|
170
172
|
specification_version: 4
|
171
173
|
summary: DownloadTV is a tool that allows the user to find magnet links for tv show
|
172
174
|
episodes. It accepts shows as arguments, from a file or it can integrate with your
|
173
175
|
MyEpisodes account.
|
174
176
|
test_files:
|
175
|
-
- test/config_test.rb
|
176
177
|
- test/downloader_test.rb
|
177
178
|
- test/grabbers_test.rb
|
178
179
|
- test/test_helper.rb
|
179
|
-
- test/torrent_test.rb
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DownloadTV
|
4
|
-
##
|
5
|
-
# Addic7ed prototype (WIP)
|
6
|
-
class Addic7ed < LinkGrabber
|
7
|
-
def initialize
|
8
|
-
super('http://www.addic7ed.com/search.php?search=%s'\
|
9
|
-
'&Submit=Search')
|
10
|
-
end
|
11
|
-
|
12
|
-
def get_subs(show)
|
13
|
-
url = get_url(show)
|
14
|
-
download_file(url)
|
15
|
-
end
|
16
|
-
|
17
|
-
def get_url(show)
|
18
|
-
# Change spaces for the separator
|
19
|
-
s = show.gsub(' ', @sep)
|
20
|
-
|
21
|
-
# Format the url
|
22
|
-
search = Format(@url, s)
|
23
|
-
|
24
|
-
agent = Mechanize.new
|
25
|
-
res = agent.get(search)
|
26
|
-
|
27
|
-
# No redirection means no subtitle found
|
28
|
-
raise NoSubtitlesError if res.uri.to_s == search
|
29
|
-
|
30
|
-
##########
|
31
|
-
# DO OPENSUBTITLES FIRST (see subtitles.rb)
|
32
|
-
#####
|
33
|
-
|
34
|
-
# We now have an URL like:
|
35
|
-
# http://www.addic7ed.com/serie/Mr._Robot/2/3/eps2.1k3rnel-pan1c.ksd
|
36
|
-
|
37
|
-
# To find the real links:
|
38
|
-
# see comments at the end of file
|
39
|
-
end
|
40
|
-
|
41
|
-
def download_file(url)
|
42
|
-
# Url must be like 'http://www.addic7ed.com/updated/1/115337/0'
|
43
|
-
|
44
|
-
# ADDIC7ED PROVIDES RSS
|
45
|
-
|
46
|
-
agent = Mechanize.new
|
47
|
-
page = agent.get(url, [], @url)
|
48
|
-
puts page.save('Hi')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
# subtitles = {}
|
53
|
-
# html.css('.tabel95 .newsDate').each do |td|
|
54
|
-
# if downloads = td.text.match(/\s(\d*)\sDownloads/i)
|
55
|
-
# done = false
|
56
|
-
# td.parent.parent.xpath('./tr/td/a[@class='buttonDownload']/@href').each do |link|
|
57
|
-
# if md = link.value.match(/updated/i)
|
58
|
-
# subtitles[downloads[1].to_i] = link.value
|
59
|
-
# done = true
|
60
|
-
# elsif link.value.match(/original/i) && done == false
|
61
|
-
# subtitles[downloads[1].to_i] = link.value
|
62
|
-
# done = true
|
63
|
-
# end
|
64
|
-
# end
|
65
|
-
# end
|
@@ -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
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DownloadTV
|
4
|
-
##
|
5
|
-
# Manages the subtitles (WIP)
|
6
|
-
class Subtitles
|
7
|
-
def initialize
|
8
|
-
@a = Addic7ed.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def get_subs(show)
|
12
|
-
@a.get_subs(show)
|
13
|
-
rescue NoSubtitlesError
|
14
|
-
puts "No subtitles found for #{show}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
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
|