download_tv 2.8.3 → 2.8.5

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: 6c202232c01422b793ebb302b44517ae6e81e8d95fa9f30dbd5a87014b88386f
4
- data.tar.gz: fdff3db7c0590cfce73cef42cb8775734bb980867901a087c8af362a764ffa9f
3
+ metadata.gz: f949ddf2dd0814373780e8b72b0186573f7b255b4704b1df13a4130cd86d0d08
4
+ data.tar.gz: 85c530552c796b1ae499a705368290d14108f82931dee5cd867184552adaf8f5
5
5
  SHA512:
6
- metadata.gz: f725cb5dff565e302ce166be63c142e5aeb3693e7379e135f3d7cb21de1f8fdae1a7df53f6a96abdf44ef94fcc16f4412c9a2d3d64da6c060ee5de6844eae5b6
7
- data.tar.gz: 07576b4a5194b8929a1107ef233154f72237c72d72d2e9c8ba787613a0f8047cdc9dade2a83501b1434b99181149f161cf946d33211caefe0ef7b269314e10fc
6
+ metadata.gz: f7cd21e015d34429eda44aed2ba7ebb1565bac83064ef512e634479b65890e46a9ac6e562378e5fe0fe926f00dcd7d07ed1b87e0a0962862db133591af35d9d5
7
+ data.tar.gz: fc2f51385747ce6305214bdd5819edaa24d2e288c631d3648d30397d5e4250b9d70a664702a5be10c7f483e552cbed4e2a04e1cf69bb6acfb70f5f8bd97f2969
@@ -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,17 @@
2
2
 
3
3
  ## Next (unreleased)
4
4
 
5
+ ## 2.8.5 (2024-09-22)
6
+
7
+ * Grabbers
8
+ * ThePirateBay: fix with upstream again...
9
+ * ThePirateBayAPI: added (disabled) in case they expose it again.
10
+
11
+ ## 2.8.4 (2024-08-19)
12
+
13
+ * Grabbers
14
+ * ThePirateBay: fix with upstream. Use tpb api.
15
+
5
16
  ## 2.8.3 (2024-02-20)
6
17
 
7
18
  * Grabbers
@@ -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
 
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DownloadTV
4
+ ##
5
+ # ThePirateBay grabber
6
+ class ThePirateBayAPI < LinkGrabber
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=")
20
+ end
21
+
22
+ def get_links(show)
23
+ search = format(@url, show)
24
+
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'
29
+
30
+ parsed.map do |elem|
31
+ [elem['name'], build_magnet(elem['info_hash'], elem['name'])]
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def build_magnet(torrent_hash, name)
38
+ "magnet:?xt=urn:btih:#{torrent_hash}&dn=#{CGI.escape(name)}#{trackers_params}"
39
+ end
40
+
41
+ def trackers_params
42
+ trackers_params ||= "&tr=#{TRACKERS.map { |tracker| CGI.escape(tracker) }.join('&tr=')}"
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DownloadTV
4
- VERSION = '2.8.3'
4
+ VERSION = '2.8.5'
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.3
4
+ version: 2.8.5
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-20 00:00:00.000000000 Z
11
+ date: 2024-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -134,6 +134,7 @@ files:
134
134
  - lib/download_tv/grabbers/torrentgalaxy.rb
135
135
  - lib/download_tv/grabbers/torrentz.rb
136
136
  - lib/download_tv/grabbers/tpb.rb
137
+ - lib/download_tv/grabbers/tpbapi.rb
137
138
  - lib/download_tv/linkgrabber.rb
138
139
  - lib/download_tv/myepisodes.rb
139
140
  - lib/download_tv/torrent.rb