download_tv 2.6.10 → 2.8.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: f8276a91948a8fc6701546da7229c00f1789a3fe1e992766189bf7ffe8bcbe0a
4
+ data.tar.gz: 3fa1290e6b9a9280562776a43ec9f202840edfc882a5884a3abc492aed2143c4
5
5
  SHA512:
6
- metadata.gz: 20aa26d49b8227b6243f408d8946a0646d26f2ee4621605fa09c6ec4945a74775b6980622722652c40deb3414708610a938f34d623c790249738245c201b884e
7
- data.tar.gz: e0a7a099cd21b7e5e8a9ee477bdd20a2bd5da61f5ed3a33d0d2adc0e6878b31c6bfedade3e7880c3006afd284800a85e88119b8608ae2ba10671d1d687d80850
6
+ metadata.gz: e45a182bed172f934e9dc0eb84feb65ee69b14df387fad4409b6ddc4f0e9bcf5e832c47e8217897298e193104dcf005b70c7e234564be3142b381a10bea8ae6b
7
+ data.tar.gz: 1c95a6c3cbdb3f9201f43b7d536f412e09879bea63c2352e59412dfd0f453b5ca59b37eceb30ba8429f97cef90d80922ad011e881819d0a059e03b39a87960f2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # download_tv CHANGELOG
2
2
 
3
+ ## 2.8.0 (2023-06-16)
4
+
5
+ * Grabbers
6
+ * TorrentGalaxy: added TorrentGalaxy grabber.
7
+
8
+ ## 2.7.0 (2023-05-31)
9
+
10
+ * Grabbers
11
+ * TorrentAPI: Removed (RARBG)
12
+
3
13
  ## 2.6.10 (2023-03-16)
4
14
 
5
15
  * 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 TorrentGalaxy. 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] ||= 'TorrentGalaxy'
144
144
  self[:date] ||= Date.today - 1
145
145
  self[:filters] ||= default_filters
146
146
  self[:pending] ||= []
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DownloadTV
4
+ ##
5
+ # TorrentGalaxy grabber
6
+ class TorrentGalaxy < LinkGrabber
7
+ def initialize
8
+ super('https://torrentgalaxy.to/torrents.php?search=%s&sort=seeders&order=desc')
9
+ end
10
+
11
+ def get_links(show)
12
+ raw_data = agent.get(format(@url, show))
13
+ rows = raw_data.search('div.tgxtablerow')
14
+
15
+ raise NoTorrentsError if rows.size == 0
16
+
17
+ rows.map do |row|
18
+ [row.children[4].text.strip,
19
+ row.children[5].children[1].attribute('href').text]
20
+ end
21
+ end
22
+ end
23
+ end
@@ -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[TorrentGalaxy 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.8.0'
5
5
  end
@@ -3,19 +3,19 @@
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') }
8
+ let(:torrentgalaxy_mock) { double('torrentgalaxy') }
9
9
  let(:test_show) { double('test_show') }
10
10
  subject { described_class.new(default_grabber) }
11
11
 
12
12
  before :each do
13
- allow(DownloadTV::TorrentAPI).to receive(:new).and_return torrentapi_mock
13
+ allow(DownloadTV::TorrentGalaxy).to receive(:new).and_return torrentgalaxy_mock
14
14
  allow(DownloadTV::Torrentz).to receive(:new).and_return torrentz_mock
15
15
  allow(DownloadTV::Eztv).to receive(:new).and_return eztv_mock
16
16
  # allow(DownloadTV::ThePirateBay).to receive(:new).and_return tpb_mock
17
17
 
18
- allow(torrentapi_mock).to receive(:online?).and_return(true)
18
+ allow(torrentgalaxy_mock).to receive(:online?).and_return(true)
19
19
  allow(torrentz_mock).to receive(:online?).and_return(true)
20
20
  allow(eztv_mock).to receive(:online?).and_return(true)
21
21
  end
@@ -23,7 +23,7 @@ describe DownloadTV::Torrent do
23
23
  describe 'Torrent.grabbers' do
24
24
  it 'returns the list of grabbers' do
25
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]
26
+ expect(described_class.grabbers).to eq %w[TorrentGalaxy Torrentz Eztv]
27
27
 
28
28
  end
29
29
  end
@@ -31,20 +31,21 @@ describe DownloadTV::Torrent do
31
31
  describe '#get_links' do
32
32
  it 'will use the first grabber and return its #get_link result' do
33
33
  result = double('result')
34
- expect(torrentapi_mock).to receive(:get_links).with(test_show).and_return(result)
34
+ expect(torrentgalaxy_mock).to receive(:get_links).with(test_show).and_return(result)
35
35
 
36
36
  result = subject.get_links(test_show)
37
37
  end
38
38
 
39
39
  context 'when the first grabber is offline' do
40
40
  before do
41
- allow(torrentapi_mock).to receive(:online?).and_return(false)
41
+ allow(torrentgalaxy_mock).to receive(:online?).and_return(false)
42
42
  end
43
43
 
44
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)
45
+ expect(torrentgalaxy_mock).not_to receive(:get_links)
47
46
  expect(torrentz_mock).to receive(:get_links).with(test_show)
47
+ expect(eztv_mock).not_to receive(:get_links)
48
+ # Add other torrents here with expectation #not_to receive
48
49
 
49
50
  result = subject.get_links(test_show)
50
51
  end
@@ -52,13 +53,13 @@ describe DownloadTV::Torrent do
52
53
 
53
54
  context 'when all the grabbers are offline' do
54
55
  before do
55
- allow(torrentapi_mock).to receive(:online?).and_return(false)
56
+ allow(torrentgalaxy_mock).to receive(:online?).and_return(false)
56
57
  allow(torrentz_mock).to receive(:online?).and_return(false)
57
58
  allow(eztv_mock).to receive(:online?).and_return(false)
58
59
  end
59
60
 
60
61
  it 'will exit' do
61
- expect(torrentapi_mock).not_to receive(:get_links)
62
+ expect(torrentgalaxy_mock).not_to receive(:get_links)
62
63
  expect(torrentz_mock).not_to receive(:get_links)
63
64
  expect(eztv_mock).not_to receive(:get_links)
64
65
 
@@ -68,14 +69,12 @@ describe DownloadTV::Torrent do
68
69
 
69
70
  context 'when one grabber does not find a link' do
70
71
  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)
72
+ allow(torrentgalaxy_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
73
73
  end
74
74
 
75
75
  it 'will keep trying until one does' do
76
- expect(torrentapi_mock).to receive(:get_links).ordered
76
+ expect(torrentgalaxy_mock).to receive(:get_links).ordered
77
77
  expect(torrentz_mock).to receive(:get_links).ordered
78
- expect(eztv_mock).to receive(:get_links).ordered
79
78
 
80
79
  result = subject.get_links(test_show)
81
80
  end
@@ -83,13 +82,13 @@ describe DownloadTV::Torrent do
83
82
 
84
83
  context 'when no grabber can find a link' do
85
84
  before do
86
- allow(torrentapi_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
85
+ allow(torrentgalaxy_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
87
86
  allow(torrentz_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
88
87
  allow(eztv_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
89
88
  end
90
89
 
91
90
  it 'will return an empty array' do
92
- expect(torrentapi_mock).to receive(:get_links).ordered
91
+ expect(torrentgalaxy_mock).to receive(:get_links).ordered
93
92
  expect(torrentz_mock).to receive(:get_links).ordered
94
93
  expect(eztv_mock).to receive(:get_links).ordered
95
94
 
@@ -102,7 +101,7 @@ describe DownloadTV::Torrent do
102
101
 
103
102
  it 'will use that grabber preferently' do
104
103
  test_show = double('test_show')
105
- expect(torrentapi_mock).not_to receive(:get_links)
104
+ expect(torrentgalaxy_mock).not_to receive(:get_links)
106
105
  expect(torrentz_mock).not_to receive(:get_links)
107
106
  expect(eztv_mock).to receive(:get_links).with(test_show)
108
107
 
@@ -113,7 +112,7 @@ describe DownloadTV::Torrent do
113
112
  context 'when a grabber fails on a run and it is called twice' do
114
113
  before do
115
114
  count = 0
116
- allow(torrentapi_mock).to receive(:get_links).exactly(2).times.with(test_show) do
115
+ allow(torrentgalaxy_mock).to receive(:get_links).exactly(2).times.with(test_show) do
117
116
  count += 1
118
117
  raise DownloadTV::NoTorrentsError if count == 1
119
118
  end
@@ -121,8 +120,9 @@ describe DownloadTV::Torrent do
121
120
  end
122
121
 
123
122
  it 'the second run will use the original order' do
124
- expect(torrentapi_mock).to receive(:get_links).exactly(2).times
123
+ expect(torrentgalaxy_mock).to receive(:get_links).exactly(2).times
125
124
  expect(torrentz_mock).to receive(:get_links).exactly(1).time
125
+ expect(eztv_mock).not_to receive(:get_links)
126
126
 
127
127
  result = subject.get_links(test_show)
128
128
  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.8.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-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -132,7 +132,7 @@ 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
135
+ - lib/download_tv/grabbers/torrentgalaxy.rb
136
136
  - lib/download_tv/grabbers/torrentz.rb
137
137
  - lib/download_tv/grabbers/tpb.rb
138
138
  - 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