download_tv 2.6.9 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/lib/download_tv/configuration.rb +1 -1
- data/lib/download_tv/torrent.rb +1 -1
- data/lib/download_tv/version.rb +1 -1
- data/spec/download_tv/torrent_spec.rb +9 -19
- metadata +2 -3
- data/lib/download_tv/grabbers/torrentapi.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60baef524397c2e513b18700b0b12df3d0e50f4ce396d360d230132526484a70
|
4
|
+
data.tar.gz: 91d36e1b5de51e2b056a0fca5696c97fd930721491aeadd584e8e73811833e32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cd4d4c64cc88873c307d12d2f4745f21b1a09ee8b69a6b78a5ee1ac2c838eabd98369e4d2b8725f3c11473a67ec47c787740d2ab805d3a5194c5ccb23d512d5
|
7
|
+
data.tar.gz: d68d9db7807b684a251be0f8a6c564c38e2df4fc868c3491ed19487a3b3056103c07dd4c0dc328844c701151b27548842dceb89a9f1fbc60637329b54fadfe7d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -69,7 +69,7 @@ The `-f` flag can be used to read the list of episodes to download from a file.
|
|
69
69
|
|
70
70
|
### Available link grabbers
|
71
71
|
|
72
|
-
With `-g` and `--show-grabbers`, the user can see what grabbers are available and choose one of these as their preferred option. By default, the application searches for torrents using
|
72
|
+
With `-g` and `--show-grabbers`, the user can see what grabbers are available and choose one of these as their preferred option. By default, the application searches for torrents using Torrentz. When a grabber doesn't have a torrent for said episode, is offline, or causes any error to appear, it skips to the next grabber until exhausting the list.
|
73
73
|
|
74
74
|
I usually publish a patch update to the gem when I detect one of them isn't working, disabling it or fixing it altogether. If a specific grabber is giving you problems, check whether you're running the latest version of the gem before opening an issue here.
|
75
75
|
|
@@ -140,7 +140,7 @@ module DownloadTV
|
|
140
140
|
# Maintains the previous values, in case it's an update from an existing file.
|
141
141
|
def set_default_values
|
142
142
|
self[:auto] ||= true
|
143
|
-
self[:grabber] ||= '
|
143
|
+
self[:grabber] ||= 'Torrentz'
|
144
144
|
self[:date] ||= Date.today - 1
|
145
145
|
self[:filters] ||= default_filters
|
146
146
|
self[:pending] ||= []
|
data/lib/download_tv/torrent.rb
CHANGED
data/lib/download_tv/version.rb
CHANGED
@@ -3,19 +3,16 @@
|
|
3
3
|
describe DownloadTV::Torrent do
|
4
4
|
let(:default_grabber) { nil }
|
5
5
|
let(:eztv_mock) { double('eztv') }
|
6
|
-
let(:torrentapi_mock) { double('torrentapi') }
|
7
6
|
let(:torrentz_mock) { double('torrentz') }
|
8
7
|
let(:tpb_mock) { double('tpb') }
|
9
8
|
let(:test_show) { double('test_show') }
|
10
9
|
subject { described_class.new(default_grabber) }
|
11
10
|
|
12
11
|
before :each do
|
13
|
-
allow(DownloadTV::TorrentAPI).to receive(:new).and_return torrentapi_mock
|
14
12
|
allow(DownloadTV::Torrentz).to receive(:new).and_return torrentz_mock
|
15
13
|
allow(DownloadTV::Eztv).to receive(:new).and_return eztv_mock
|
16
14
|
# allow(DownloadTV::ThePirateBay).to receive(:new).and_return tpb_mock
|
17
15
|
|
18
|
-
allow(torrentapi_mock).to receive(:online?).and_return(true)
|
19
16
|
allow(torrentz_mock).to receive(:online?).and_return(true)
|
20
17
|
allow(eztv_mock).to receive(:online?).and_return(true)
|
21
18
|
end
|
@@ -23,7 +20,7 @@ describe DownloadTV::Torrent do
|
|
23
20
|
describe 'Torrent.grabbers' do
|
24
21
|
it 'returns the list of grabbers' do
|
25
22
|
# This order is assumed in the other specs, so explicitly checking it here
|
26
|
-
expect(described_class.grabbers).to eq %w[
|
23
|
+
expect(described_class.grabbers).to eq %w[Torrentz Eztv]
|
27
24
|
|
28
25
|
end
|
29
26
|
end
|
@@ -31,20 +28,20 @@ describe DownloadTV::Torrent do
|
|
31
28
|
describe '#get_links' do
|
32
29
|
it 'will use the first grabber and return its #get_link result' do
|
33
30
|
result = double('result')
|
34
|
-
expect(
|
31
|
+
expect(torrentz_mock).to receive(:get_links).with(test_show).and_return(result)
|
35
32
|
|
36
33
|
result = subject.get_links(test_show)
|
37
34
|
end
|
38
35
|
|
39
36
|
context 'when the first grabber is offline' do
|
40
37
|
before do
|
41
|
-
allow(
|
38
|
+
allow(torrentz_mock).to receive(:online?).and_return(false)
|
42
39
|
end
|
43
40
|
|
44
41
|
it 'will use the second grabber' do
|
45
|
-
expect(
|
46
|
-
expect(eztv_mock).
|
47
|
-
|
42
|
+
expect(torrentz_mock).not_to receive(:get_links)
|
43
|
+
expect(eztv_mock).to receive(:get_links).with(test_show)
|
44
|
+
# Add other torrents here with expectation #not_to receive
|
48
45
|
|
49
46
|
result = subject.get_links(test_show)
|
50
47
|
end
|
@@ -52,13 +49,11 @@ describe DownloadTV::Torrent do
|
|
52
49
|
|
53
50
|
context 'when all the grabbers are offline' do
|
54
51
|
before do
|
55
|
-
allow(torrentapi_mock).to receive(:online?).and_return(false)
|
56
52
|
allow(torrentz_mock).to receive(:online?).and_return(false)
|
57
53
|
allow(eztv_mock).to receive(:online?).and_return(false)
|
58
54
|
end
|
59
55
|
|
60
56
|
it 'will exit' do
|
61
|
-
expect(torrentapi_mock).not_to receive(:get_links)
|
62
57
|
expect(torrentz_mock).not_to receive(:get_links)
|
63
58
|
expect(eztv_mock).not_to receive(:get_links)
|
64
59
|
|
@@ -68,12 +63,10 @@ describe DownloadTV::Torrent do
|
|
68
63
|
|
69
64
|
context 'when one grabber does not find a link' do
|
70
65
|
before do
|
71
|
-
allow(torrentapi_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
72
66
|
allow(torrentz_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
73
67
|
end
|
74
68
|
|
75
69
|
it 'will keep trying until one does' do
|
76
|
-
expect(torrentapi_mock).to receive(:get_links).ordered
|
77
70
|
expect(torrentz_mock).to receive(:get_links).ordered
|
78
71
|
expect(eztv_mock).to receive(:get_links).ordered
|
79
72
|
|
@@ -83,13 +76,11 @@ describe DownloadTV::Torrent do
|
|
83
76
|
|
84
77
|
context 'when no grabber can find a link' do
|
85
78
|
before do
|
86
|
-
allow(torrentapi_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
87
79
|
allow(torrentz_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
88
80
|
allow(eztv_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
|
89
81
|
end
|
90
82
|
|
91
83
|
it 'will return an empty array' do
|
92
|
-
expect(torrentapi_mock).to receive(:get_links).ordered
|
93
84
|
expect(torrentz_mock).to receive(:get_links).ordered
|
94
85
|
expect(eztv_mock).to receive(:get_links).ordered
|
95
86
|
|
@@ -102,7 +93,6 @@ describe DownloadTV::Torrent do
|
|
102
93
|
|
103
94
|
it 'will use that grabber preferently' do
|
104
95
|
test_show = double('test_show')
|
105
|
-
expect(torrentapi_mock).not_to receive(:get_links)
|
106
96
|
expect(torrentz_mock).not_to receive(:get_links)
|
107
97
|
expect(eztv_mock).to receive(:get_links).with(test_show)
|
108
98
|
|
@@ -113,7 +103,7 @@ describe DownloadTV::Torrent do
|
|
113
103
|
context 'when a grabber fails on a run and it is called twice' do
|
114
104
|
before do
|
115
105
|
count = 0
|
116
|
-
allow(
|
106
|
+
allow(torrentz_mock).to receive(:get_links).exactly(2).times.with(test_show) do
|
117
107
|
count += 1
|
118
108
|
raise DownloadTV::NoTorrentsError if count == 1
|
119
109
|
end
|
@@ -121,8 +111,8 @@ describe DownloadTV::Torrent do
|
|
121
111
|
end
|
122
112
|
|
123
113
|
it 'the second run will use the original order' do
|
124
|
-
expect(
|
125
|
-
expect(
|
114
|
+
expect(torrentz_mock).to receive(:get_links).exactly(2).times
|
115
|
+
expect(eztv_mock).to receive(:get_links).exactly(1).time
|
126
116
|
|
127
117
|
result = subject.get_links(test_show)
|
128
118
|
result = subject.get_links(test_show)
|
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.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- guille
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,7 +132,6 @@ files:
|
|
132
132
|
- lib/download_tv/downloader.rb
|
133
133
|
- lib/download_tv/filterer.rb
|
134
134
|
- lib/download_tv/grabbers/eztv.rb
|
135
|
-
- lib/download_tv/grabbers/torrentapi.rb
|
136
135
|
- lib/download_tv/grabbers/torrentz.rb
|
137
136
|
- lib/download_tv/grabbers/tpb.rb
|
138
137
|
- lib/download_tv/linkgrabber.rb
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DownloadTV
|
4
|
-
##
|
5
|
-
# TorrentAPI.org grabber
|
6
|
-
# Interfaces with http://torrentapi.org/apidocs_v2.txt
|
7
|
-
class TorrentAPI < LinkGrabber
|
8
|
-
TOKEN_EXPIRED_ERROR = 4
|
9
|
-
TOO_MANY_REQUESTS_ERROR = 5 # 1req/2s
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
super('https://torrentapi.org/pubapi_v2.php?'\
|
13
|
-
'mode=search&search_string=%s&token=%s&'\
|
14
|
-
'app_id=DownloadTV&sort=seeders')
|
15
|
-
@wait = 0.5
|
16
|
-
@token = nil
|
17
|
-
end
|
18
|
-
|
19
|
-
##
|
20
|
-
# Specific implementation for TorrentAPI (requires token)
|
21
|
-
def online?
|
22
|
-
renew_token
|
23
|
-
true
|
24
|
-
rescue Mechanize::ResponseCodeError => e
|
25
|
-
if e.response_code == '429'
|
26
|
-
sleep(@wait)
|
27
|
-
retry
|
28
|
-
end
|
29
|
-
false
|
30
|
-
rescue Net::HTTP::Persistent::Error
|
31
|
-
false
|
32
|
-
end
|
33
|
-
|
34
|
-
##
|
35
|
-
# Makes a get request tp the given url.
|
36
|
-
# Returns the JSON response parsed into a hash
|
37
|
-
def request_and_parse(url)
|
38
|
-
page = agent.get(url).content
|
39
|
-
JSON.parse(page)
|
40
|
-
end
|
41
|
-
|
42
|
-
##
|
43
|
-
# Connects to Torrentapi.org and requests a token, returning it
|
44
|
-
# Tokens automatically expire every 15 minutes
|
45
|
-
def renew_token
|
46
|
-
obj = request_and_parse('https://torrentapi.org/pubapi_v2'\
|
47
|
-
'.php?get_token=get_token&app_id='\
|
48
|
-
'DownloadTV')
|
49
|
-
|
50
|
-
@token = obj['token']
|
51
|
-
end
|
52
|
-
|
53
|
-
def get_links(show)
|
54
|
-
renew_token if @token.nil?
|
55
|
-
|
56
|
-
search = format(@url, show, @token)
|
57
|
-
|
58
|
-
obj = request_and_parse(search)
|
59
|
-
|
60
|
-
if obj['error_code'] == TOKEN_EXPIRED_ERROR
|
61
|
-
renew_token
|
62
|
-
search = format(@url, show, @token)
|
63
|
-
obj = request_and_parse(search)
|
64
|
-
end
|
65
|
-
|
66
|
-
until obj['error_code'] != TOO_MANY_REQUESTS_ERROR && (obj['rate_limit'].nil? || obj['rate_limit'] == false)
|
67
|
-
sleep(@wait)
|
68
|
-
obj = request_and_parse(search)
|
69
|
-
end
|
70
|
-
|
71
|
-
raise NoTorrentsError if obj['error']
|
72
|
-
|
73
|
-
names = obj['torrent_results'].collect { |i| i['filename'] }
|
74
|
-
links = obj['torrent_results'].collect { |i| i['download'] }
|
75
|
-
|
76
|
-
names.zip(links)
|
77
|
-
rescue Mechanize::ResponseCodeError => e
|
78
|
-
if e.response_code == '429'
|
79
|
-
sleep(@wait)
|
80
|
-
retry
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|