download_tv 2.6.10 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '003218a860babed3e80f3e3c49d0ec1b34b5cb4ccd5f3d76e6cb22c7d1bba398'
4
- data.tar.gz: 6f0f5d1b4fc0837cfdfa04b0a6d9cc1a3af93488d13b3f571de7813beb65e0c7
3
+ metadata.gz: 60baef524397c2e513b18700b0b12df3d0e50f4ce396d360d230132526484a70
4
+ data.tar.gz: 91d36e1b5de51e2b056a0fca5696c97fd930721491aeadd584e8e73811833e32
5
5
  SHA512:
6
- metadata.gz: 20aa26d49b8227b6243f408d8946a0646d26f2ee4621605fa09c6ec4945a74775b6980622722652c40deb3414708610a938f34d623c790249738245c201b884e
7
- data.tar.gz: e0a7a099cd21b7e5e8a9ee477bdd20a2bd5da61f5ed3a33d0d2adc0e6878b31c6bfedade3e7880c3006afd284800a85e88119b8608ae2ba10671d1d687d80850
6
+ metadata.gz: 6cd4d4c64cc88873c307d12d2f4745f21b1a09ee8b69a6b78a5ee1ac2c838eabd98369e4d2b8725f3c11473a67ec47c787740d2ab805d3a5194c5ccb23d512d5
7
+ data.tar.gz: d68d9db7807b684a251be0f8a6c564c38e2df4fc868c3491ed19487a3b3056103c07dd4c0dc328844c701151b27548842dceb89a9f1fbc60637329b54fadfe7d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # download_tv CHANGELOG
2
2
 
3
+ ## 2.7.0 (2023-05-31)
4
+
5
+ * Grabbers
6
+ * TorrentAPI: Removed (RARBG)
7
+
3
8
  ## 2.6.10 (2023-03-16)
4
9
 
5
10
  * Fixes
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 TorrentAPI. 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.
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] ||= 'TorrentAPI'
143
+ self[:grabber] ||= 'Torrentz'
144
144
  self[:date] ||= Date.today - 1
145
145
  self[:filters] ||= default_filters
146
146
  self[:pending] ||= []
@@ -6,7 +6,7 @@ module DownloadTV
6
6
  class Torrent
7
7
  class << self
8
8
  def grabbers
9
- %w[TorrentAPI Torrentz Eztv]
9
+ %w[Torrentz Eztv]
10
10
  end
11
11
 
12
12
  def healthcheck
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DownloadTV
4
- VERSION = '2.6.10'
4
+ VERSION = '2.7.0'
5
5
  end
@@ -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[TorrentAPI Torrentz Eztv]
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(torrentapi_mock).to receive(:get_links).with(test_show).and_return(result)
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(torrentapi_mock).to receive(:online?).and_return(false)
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(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)
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(torrentapi_mock).to receive(:get_links).exactly(2).times.with(test_show) do
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(torrentapi_mock).to receive(:get_links).exactly(2).times
125
- expect(torrentz_mock).to receive(:get_links).exactly(1).time
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.6.10
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-03-16 00:00:00.000000000 Z
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,87 +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 = 1.5
16
- @token = nil
17
- @retries_left = 5
18
- end
19
-
20
- ##
21
- # Specific implementation for TorrentAPI (requires token)
22
- def online?
23
- renew_token
24
- true
25
- rescue Mechanize::ResponseCodeError => e
26
- if e.response_code == '429'
27
- sleep(@wait)
28
- retry
29
- end
30
- false
31
- rescue Net::HTTP::Persistent::Error
32
- false
33
- end
34
-
35
- ##
36
- # Makes a get request tp the given url.
37
- # Returns the JSON response parsed into a hash
38
- def request_and_parse(url)
39
- page = agent.get(url).content
40
- JSON.parse(page)
41
- end
42
-
43
- ##
44
- # Connects to Torrentapi.org and requests a token, returning it
45
- # Tokens automatically expire every 15 minutes
46
- def renew_token
47
- obj = request_and_parse('https://torrentapi.org/pubapi_v2'\
48
- '.php?get_token=get_token&app_id='\
49
- 'DownloadTV')
50
-
51
- @token = obj['token']
52
- end
53
-
54
- def get_links(show)
55
- renew_token if @token.nil?
56
-
57
- search = format(@url, show, @token)
58
-
59
- obj = request_and_parse(search)
60
-
61
- if obj['error_code'] == TOKEN_EXPIRED_ERROR
62
- renew_token
63
- search = format(@url, show, @token)
64
- obj = request_and_parse(search)
65
- end
66
-
67
- until obj['error_code'] != TOO_MANY_REQUESTS_ERROR && (obj['rate_limit'].nil? || obj['rate_limit'] == false)
68
- sleep(@wait)
69
- obj = request_and_parse(search)
70
- end
71
-
72
- raise NoTorrentsError if obj['error']
73
-
74
- names = obj['torrent_results'].collect { |i| i['filename'] }
75
- links = obj['torrent_results'].collect { |i| i['download'] }
76
-
77
- names.zip(links)
78
- rescue Mechanize::ResponseCodeError => e
79
- if (e.response_code == '429' || e.response_code == '520') && @retries_left > 0
80
- sleep(@wait)
81
- @retries_left -= 1
82
- retry
83
- end
84
- raise NoTorrentsError
85
- end
86
- end
87
- end