download_tv 2.8.2 → 2.8.4

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: dc98fbb05c628ba5b0190151709402f5fd51e4347d01877303a0b4095f860a84
4
- data.tar.gz: 279634198b716bf905e49e30f5914ed28a9992be541a4fc27c5c3836779b5704
3
+ metadata.gz: c39ab8c419d632acdd80ea9a072dbb119e27bec036d8e631bd1fe677a7cdc133
4
+ data.tar.gz: 6df0b53c0faedfa474631b8fb9c071b2bb3465a0b2172e599e2cd57d3d07b995
5
5
  SHA512:
6
- metadata.gz: ac807e4d8f2f9dccecc80b50aec2216cdb0d3e7d78a590ee7fd3358c1b863a2ce0ada79bc991cd6f93e271f13a7607f35ce76a4f41e70ee0c074c8147aafa9ce
7
- data.tar.gz: 64b2de934b6794a130b5f4685587ef91170ba30fde9a5b0ad0db290497804fbeac71a01e5e4ed99a45cf324158a266e56830f43bdc3ff0c7c79e38ae1d8e0ae3
6
+ metadata.gz: e455efa1fb3c2a86b480f3e1cbc814dc97297e45f26eb3b611cd740d19033682980e2f4a85a69b8f9b16f2575806d625a63290b631966788838bde3001b9c803
7
+ data.tar.gz: 65d73597d67dc3f03280d18d32d11a1b32d10e1c53ea3b8bac6cdda910de4af2800e90010d6a558906830837d770a2e96229059a620d62307b8935832b20ec61
@@ -15,19 +15,15 @@ on:
15
15
 
16
16
  jobs:
17
17
  test:
18
-
19
18
  runs-on: ubuntu-latest
20
19
  strategy:
21
20
  matrix:
22
- ruby-version: ['2.6', '2.7', '3.0']
21
+ ruby-version: ['2.7', '3.0']
23
22
 
24
23
  steps:
25
24
  - uses: actions/checkout@v2
26
25
  - name: Set up Ruby
27
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
- # uses: ruby/setup-ruby@v1
30
- uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
26
+ uses: ruby/setup-ruby@v1
31
27
  with:
32
28
  ruby-version: ${{ matrix.ruby-version }}
33
29
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## Next (unreleased)
4
4
 
5
+ ## 2.8.4 (2024-08-19)
6
+
7
+ * Grabbers
8
+ * ThePirateBay: fix with upstream. Use tpb api.
9
+
10
+ ## 2.8.3 (2024-02-20)
11
+
12
+ * Grabbers
13
+ * TorrentGalaxy: disable grabber.
14
+ * Torrentz: made the new default.
15
+ * ThePirateBay: re-enable grabber with new proxy URL.
16
+
5
17
  ## 2.8.2 (2024-02-16)
6
18
 
7
19
  * Improvements
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 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.
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] ||= 'TorrentGalaxy'
143
+ self[:grabber] ||= 'Torrentz'
144
144
  self[:date] ||= Date.today - 1
145
145
  self[:filters] ||= default_filters
146
146
  self[:pending] ||= []
@@ -180,8 +180,9 @@ module DownloadTV
180
180
  def reject_ignored(shows)
181
181
  shows.reject do |i|
182
182
  # Remove season+episode
183
- @config[:ignored]
184
- .include?(i.split(' ')[0..-2].join(' ').downcase)
183
+ @config[:ignored].include?(
184
+ i.split(' ')[0..-2].join(' ').downcase
185
+ )
185
186
  end
186
187
  end
187
188
 
@@ -4,27 +4,42 @@ module DownloadTV
4
4
  ##
5
5
  # ThePirateBay grabber
6
6
  class ThePirateBay < LinkGrabber
7
- def initialize(tpb_proxy = 'https://pirateproxy.sh/')
8
- proxy = tpb_proxy.gsub(%r{/+$}, '')
9
-
10
- super("#{proxy}/search/%s/0/7/0")
7
+ TRACKERS = %w[
8
+ udp://tracker.coppersurfer.tk:6969/announce
9
+ udp://tracker.openbittorrent.com:6969/announce
10
+ udp://tracker.opentrackr.org:1337
11
+ udp://movies.zsw.ca:6969/announce
12
+ udp://tracker.dler.org:6969/announce
13
+ udp://opentracker.i2p.rocks:6969/announce
14
+ udp://open.stealth.si:80/announce
15
+ udp://tracker.0x.tf:6969/announce
16
+ ]
17
+
18
+ def initialize
19
+ super("https://tpb36.ukpass.co/apibay/q.php?q=%s&cat=")
11
20
  end
12
21
 
13
22
  def get_links(show)
14
23
  search = format(@url, show)
15
24
 
16
- # Skip the header
17
- data = agent.get(search).search('#searchResult tr').drop 1
25
+ data = agent.get(search)
26
+ parsed = JSON.parse(data.body)
27
+
28
+ raise NoTorrentsError if parsed.size == 1 && parsed.first['name'] == 'No results returned'
18
29
 
19
- raise NoTorrentsError if data.empty?
30
+ parsed.map do |elem|
31
+ [elem['name'], build_magnet(elem['info_hash'], elem['name'])]
32
+ end
33
+ end
20
34
 
21
- # Second cell of each row contains links and name
22
- results = data.map { |d| d.search('td')[1] }
35
+ private
23
36
 
24
- names = results.collect { |i| i.search('.detName').text.strip }
25
- links = results.collect { |i| i.search('a')[1].attribute('href').text }
37
+ def build_magnet(torrent_hash, name)
38
+ "magnet:?xt=urn:btih:#{torrent_hash}&dn=#{CGI.escape(name)}#{trackers_params}"
39
+ end
26
40
 
27
- names.zip(links)
41
+ def trackers_params
42
+ trackers_params ||= "&tr=#{TRACKERS.map { |tracker| CGI.escape(tracker) }.join('&tr=')}"
28
43
  end
29
44
  end
30
45
  end
@@ -6,7 +6,7 @@ module DownloadTV
6
6
  class Torrent
7
7
  class << self
8
8
  def grabbers
9
- %w[TorrentGalaxy Torrentz Eztv]
9
+ %w[Torrentz ThePirateBay 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.8.2'
4
+ VERSION = '2.8.4'
5
5
  end
@@ -2,28 +2,29 @@
2
2
 
3
3
  describe DownloadTV::Torrent do
4
4
  let(:default_grabber) { nil }
5
- let(:eztv_mock) { double('eztv') }
6
- let(:torrentz_mock) { double('torrentz') }
7
- let(:tpb_mock) { double('tpb') }
8
- let(:torrentgalaxy_mock) { double('torrentgalaxy') }
5
+ let(:third_grabber) { double('eztv') }
6
+ let(:second_grabber) { double('torrentz') }
7
+ let(:fourth_grabber) { double('tpb') }
8
+ let(:first_grabber) { 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::TorrentGalaxy).to receive(:new).and_return torrentgalaxy_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(torrentgalaxy_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)
13
+ allow(DownloadTV::Torrentz).to receive(:new).and_return first_grabber
14
+ allow(DownloadTV::ThePirateBay).to receive(:new).and_return second_grabber
15
+ allow(DownloadTV::Eztv).to receive(:new).and_return third_grabber
16
+ # allow(DownloadTV::TorrentGalaxy).to receive(:new).and_return fourth_grabber
17
+
18
+ allow(first_grabber).to receive(:online?).and_return(true)
19
+ allow(second_grabber).to receive(:online?).and_return(true)
20
+ allow(third_grabber).to receive(:online?).and_return(true)
21
+ # allow(fourth_grabber).to receive(:online?).and_return(true)
21
22
  end
22
23
 
23
24
  describe 'Torrent.grabbers' do
24
25
  it 'returns the list of grabbers' do
25
26
  # This order is assumed in the other specs, so explicitly checking it here
26
- expect(described_class.grabbers).to eq %w[TorrentGalaxy Torrentz Eztv]
27
+ expect(described_class.grabbers).to eq %w[Torrentz ThePirateBay Eztv]
27
28
 
28
29
  end
29
30
  end
@@ -31,20 +32,20 @@ describe DownloadTV::Torrent do
31
32
  describe '#get_links' do
32
33
  it 'will use the first grabber and return its #get_link result' do
33
34
  result = double('result')
34
- expect(torrentgalaxy_mock).to receive(:get_links).with(test_show).and_return(result)
35
+ expect(first_grabber).to receive(:get_links).with(test_show).and_return(result)
35
36
 
36
37
  result = subject.get_links(test_show)
37
38
  end
38
39
 
39
40
  context 'when the first grabber is offline' do
40
41
  before do
41
- allow(torrentgalaxy_mock).to receive(:online?).and_return(false)
42
+ allow(first_grabber).to receive(:online?).and_return(false)
42
43
  end
43
44
 
44
45
  it 'will use the second grabber' do
45
- expect(torrentgalaxy_mock).not_to receive(:get_links)
46
- expect(torrentz_mock).to receive(:get_links).with(test_show)
47
- expect(eztv_mock).not_to receive(:get_links)
46
+ expect(first_grabber).not_to receive(:get_links)
47
+ expect(second_grabber).to receive(:get_links).with(test_show)
48
+ expect(third_grabber).not_to receive(:get_links)
48
49
  # Add other torrents here with expectation #not_to receive
49
50
 
50
51
  result = subject.get_links(test_show)
@@ -53,15 +54,15 @@ describe DownloadTV::Torrent do
53
54
 
54
55
  context 'when all the grabbers are offline' do
55
56
  before do
56
- allow(torrentgalaxy_mock).to receive(:online?).and_return(false)
57
- allow(torrentz_mock).to receive(:online?).and_return(false)
58
- allow(eztv_mock).to receive(:online?).and_return(false)
57
+ allow(first_grabber).to receive(:online?).and_return(false)
58
+ allow(second_grabber).to receive(:online?).and_return(false)
59
+ allow(third_grabber).to receive(:online?).and_return(false)
59
60
  end
60
61
 
61
62
  it 'will exit' do
62
- expect(torrentgalaxy_mock).not_to receive(:get_links)
63
- expect(torrentz_mock).not_to receive(:get_links)
64
- expect(eztv_mock).not_to receive(:get_links)
63
+ expect(first_grabber).not_to receive(:get_links)
64
+ expect(second_grabber).not_to receive(:get_links)
65
+ expect(third_grabber).not_to receive(:get_links)
65
66
 
66
67
  expect { subject.get_links(test_show) }.to raise_error(SystemExit)
67
68
  end
@@ -69,12 +70,12 @@ describe DownloadTV::Torrent do
69
70
 
70
71
  context 'when one grabber does not find a link' do
71
72
  before do
72
- allow(torrentgalaxy_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
73
+ allow(first_grabber).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
73
74
  end
74
75
 
75
76
  it 'will keep trying until one does' do
76
- expect(torrentgalaxy_mock).to receive(:get_links).ordered
77
- expect(torrentz_mock).to receive(:get_links).ordered
77
+ expect(first_grabber).to receive(:get_links).ordered
78
+ expect(second_grabber).to receive(:get_links).ordered
78
79
 
79
80
  result = subject.get_links(test_show)
80
81
  end
@@ -82,15 +83,15 @@ describe DownloadTV::Torrent do
82
83
 
83
84
  context 'when no grabber can find a link' do
84
85
  before do
85
- allow(torrentgalaxy_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
86
- allow(torrentz_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
87
- allow(eztv_mock).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
86
+ allow(first_grabber).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
87
+ allow(second_grabber).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
88
+ allow(third_grabber).to receive(:get_links).with(test_show).and_raise(DownloadTV::NoTorrentsError)
88
89
  end
89
90
 
90
91
  it 'will return an empty array' do
91
- expect(torrentgalaxy_mock).to receive(:get_links).ordered
92
- expect(torrentz_mock).to receive(:get_links).ordered
93
- expect(eztv_mock).to receive(:get_links).ordered
92
+ expect(first_grabber).to receive(:get_links).ordered
93
+ expect(second_grabber).to receive(:get_links).ordered
94
+ expect(third_grabber).to receive(:get_links).ordered
94
95
 
95
96
  expect(subject.get_links(test_show)).to eq []
96
97
  end
@@ -101,9 +102,9 @@ describe DownloadTV::Torrent do
101
102
 
102
103
  it 'will use that grabber preferently' do
103
104
  test_show = double('test_show')
104
- expect(torrentgalaxy_mock).not_to receive(:get_links)
105
- expect(torrentz_mock).not_to receive(:get_links)
106
- expect(eztv_mock).to receive(:get_links).with(test_show)
105
+ expect(first_grabber).not_to receive(:get_links)
106
+ expect(second_grabber).not_to receive(:get_links)
107
+ expect(third_grabber).to receive(:get_links).with(test_show)
107
108
 
108
109
  result = subject.get_links(test_show)
109
110
  end
@@ -112,7 +113,7 @@ describe DownloadTV::Torrent do
112
113
  context 'when a grabber fails on a run and it is called twice' do
113
114
  before do
114
115
  count = 0
115
- allow(torrentgalaxy_mock).to receive(:get_links).exactly(2).times.with(test_show) do
116
+ allow(first_grabber).to receive(:get_links).exactly(2).times.with(test_show) do
116
117
  count += 1
117
118
  raise DownloadTV::NoTorrentsError if count == 1
118
119
  end
@@ -120,9 +121,9 @@ describe DownloadTV::Torrent do
120
121
  end
121
122
 
122
123
  it 'the second run will use the original order' do
123
- expect(torrentgalaxy_mock).to receive(:get_links).exactly(2).times
124
- expect(torrentz_mock).to receive(:get_links).exactly(1).time
125
- expect(eztv_mock).not_to receive(:get_links)
124
+ expect(first_grabber).to receive(:get_links).exactly(2).times
125
+ expect(second_grabber).to receive(:get_links).exactly(1).time
126
+ expect(third_grabber).not_to receive(:get_links)
126
127
 
127
128
  result = subject.get_links(test_show)
128
129
  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.8.2
4
+ version: 2.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - guille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-16 00:00:00.000000000 Z
11
+ date: 2024-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler