download_tv 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/bin/tv +1 -1
- data/lib/download_tv/downloader.rb +7 -6
- data/lib/download_tv/grabbers/kat.rb +10 -14
- data/lib/download_tv/grabbers/torrentapi.rb +4 -8
- data/lib/download_tv/grabbers/tpb.rb +2 -2
- data/lib/download_tv/linkgrabber.rb +1 -1
- data/lib/download_tv/torrent.rb +27 -23
- data/lib/download_tv/version.rb +1 -1
- data/test/torrent_test.rb +0 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e71de7a1656a868e74d337bc5d449adcaa4dadd71ad6c2d6948046de1b86d82
|
4
|
+
data.tar.gz: 6005ca37c600b71d97a5c724b5790b7c13a34fd99256e2196e0c39461736bdbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d886c71d0106d3420e8228d95b3b4a7715b0fc0402785ab6a06aa47f9b28a737114f92514745c2d62d43272b5a7b12c1ade39e31d5e925dc63aaaf3c9cc04bf6
|
7
|
+
data.tar.gz: 6f4c082d0332f4baeaedc864a8d17487540a4723f8e1fd2b8096f98974ace3cc0c3fef0235de784150dc43d2a1e0fd166d003530479071012e1e33a8cf606254
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ The options -c and --show-config allow the user to change or view the current co
|
|
45
45
|
|
46
46
|
The `auto` flag toggles whether all the results for each show are prompted to the user for him to choose or if the application should try to choose the download link automatically (by default, prioritizes PROPER/REPACK releases at 480p).
|
47
47
|
|
48
|
-
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 searchs for torrents in TorrentAPI, ThePirateBay,
|
48
|
+
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 searchs for torrents in TorrentAPI, ThePirateBay, EZTV and KAT, in that order, skipping to the next when one of them is down/doesn't have a torrent for said episode.
|
49
49
|
|
50
50
|
### License
|
51
51
|
|
data/bin/tv
CHANGED
@@ -90,7 +90,7 @@ begin
|
|
90
90
|
rescue Interrupt
|
91
91
|
puts 'Interrupt signal detected. Exiting...'
|
92
92
|
exit 1
|
93
|
-
rescue SocketError, Errno::ECONNRESET, Net::OpenTimeout
|
93
|
+
rescue SocketError, Errno::ECONNRESET, Net::OpenTimeout, Net::ReadTimeout
|
94
94
|
warn 'Connection error.'
|
95
95
|
exit 1
|
96
96
|
end
|
@@ -26,13 +26,14 @@ module DownloadTV
|
|
26
26
|
##
|
27
27
|
# Given a file containing a list of episodes (one per line), it tries to find download links for each
|
28
28
|
def download_from_file(filename)
|
29
|
-
if
|
29
|
+
if File.exist? filename
|
30
|
+
filename = File.realpath(filename)
|
31
|
+
t = Torrent.new(@config.content[:grabber])
|
32
|
+
File.readlines(filename).each { |show| download(get_link(t, show.chomp)) }
|
33
|
+
else
|
30
34
|
puts "Error: #{filename} not found"
|
31
35
|
exit 1
|
32
36
|
end
|
33
|
-
filename = File.realpath(filename)
|
34
|
-
t = Torrent.new(@config.content[:grabber])
|
35
|
-
File.readlines(filename).each { |show| download(get_link(t, show)) }
|
36
37
|
end
|
37
38
|
|
38
39
|
##
|
@@ -45,13 +46,13 @@ module DownloadTV
|
|
45
46
|
# Log in using cookie by default
|
46
47
|
myepisodes.load_cookie
|
47
48
|
shows = myepisodes.get_shows(date)
|
49
|
+
to_download = fix_names(shows)
|
48
50
|
|
49
|
-
if
|
51
|
+
if to_download.empty?
|
50
52
|
puts 'Nothing to download'
|
51
53
|
|
52
54
|
else
|
53
55
|
t = Torrent.new(@config.content[:grabber])
|
54
|
-
to_download = fix_names(shows)
|
55
56
|
|
56
57
|
queue = Queue.new
|
57
58
|
|
@@ -3,26 +3,22 @@ module DownloadTV
|
|
3
3
|
# KATcr.co grabber
|
4
4
|
class KAT < LinkGrabber
|
5
5
|
def initialize
|
6
|
-
super('https://katcr.co/
|
6
|
+
super('https://katcr.co/advanced-usearch/')
|
7
7
|
end
|
8
8
|
|
9
9
|
def get_links(s)
|
10
|
-
|
11
|
-
|
10
|
+
params = {
|
11
|
+
'category': 'TV',
|
12
|
+
'orderby': 'seeds-desc',
|
13
|
+
'search': s
|
14
|
+
}
|
12
15
|
|
13
|
-
data = @agent.
|
16
|
+
data = @agent.post(@url, params).search('table.torrents_table tbody tr td[1]')
|
14
17
|
|
15
|
-
|
18
|
+
names = data.map { |i| i.search('a.torrents_table__torrent_title b').text }
|
19
|
+
links = data.map { |i| i.search('div.torrents_table__actions a[3]').first.attribute('href').text }
|
16
20
|
|
17
|
-
|
18
|
-
data.keep_if { |i| i.text != '' }
|
19
|
-
|
20
|
-
names = data.collect(&:text)
|
21
|
-
links = []
|
22
|
-
|
23
|
-
data.each do |res|
|
24
|
-
links << res.click.search('a.kaGiantButton[title="Magnet link"]').attribute('href').text
|
25
|
-
end
|
21
|
+
raise NoTorrentsError if data.empty?
|
26
22
|
|
27
23
|
names.zip(links)
|
28
24
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module DownloadTV
|
2
2
|
##
|
3
3
|
# TorrentAPI.org grabber
|
4
|
+
# Interfaces with http://torrentapi.org/apidocs_v2.txt
|
4
5
|
class TorrentAPI < LinkGrabber
|
5
6
|
attr_accessor :token
|
6
7
|
attr_reader :wait
|
@@ -14,24 +15,21 @@ module DownloadTV
|
|
14
15
|
# Specific implementation for TorrentAPI (requires token)
|
15
16
|
def online?
|
16
17
|
@agent.read_timeout = 2
|
17
|
-
@agent.
|
18
|
+
@agent.head(format(@url, 'test', 'test'))
|
18
19
|
true
|
19
20
|
rescue Mechanize::ResponseCodeError, Net::HTTP::Persistent::Error
|
20
21
|
false
|
21
22
|
end
|
22
23
|
|
23
24
|
##
|
24
|
-
# Connects to Torrentapi.org and requests a token
|
25
|
-
#
|
25
|
+
# Connects to Torrentapi.org and requests a token, returning it
|
26
|
+
# Tokens automatically expire every 15 minutes
|
26
27
|
def renew_token
|
27
28
|
page = @agent.get('https://torrentapi.org/pubapi_v2.php?get_token=get_token&app_id=DownloadTV').content
|
28
29
|
|
29
30
|
obj = JSON.parse(page)
|
30
31
|
|
31
32
|
@token = obj['token']
|
32
|
-
# Tokens automaticly expire in 15 minutes.
|
33
|
-
# The api has a 1req/2s limit.
|
34
|
-
# http://torrentapi.org/apidocs_v2.txt
|
35
33
|
end
|
36
34
|
|
37
35
|
def get_links(s)
|
@@ -51,11 +49,9 @@ module DownloadTV
|
|
51
49
|
end
|
52
50
|
|
53
51
|
while obj['error_code'] == 5 # Violate 1req/2s limit
|
54
|
-
# puts 'Torrentapi request limit hit. Wait a few seconds...'
|
55
52
|
sleep(@wait)
|
56
53
|
page = @agent.get(search).content
|
57
54
|
obj = JSON.parse(page)
|
58
|
-
|
59
55
|
end
|
60
56
|
|
61
57
|
raise NoTorrentsError if obj['error']
|
@@ -2,8 +2,8 @@ module DownloadTV
|
|
2
2
|
##
|
3
3
|
# ThePirateBay grabber
|
4
4
|
class ThePirateBay < LinkGrabber
|
5
|
-
def initialize(tpb_proxy = 'https://
|
6
|
-
proxy = tpb_proxy.gsub(%r{/+$}, '')
|
5
|
+
def initialize(tpb_proxy = 'https://pirateproxy.sh/')
|
6
|
+
proxy = tpb_proxy.gsub(%r{/+$}, '')
|
7
7
|
|
8
8
|
super("#{proxy}/search/%s/0/7/0")
|
9
9
|
end
|
data/lib/download_tv/torrent.rb
CHANGED
@@ -2,44 +2,43 @@ module DownloadTV
|
|
2
2
|
##
|
3
3
|
# Class in charge of managing the link grabbers
|
4
4
|
class Torrent
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :g_instances, :tries
|
6
6
|
|
7
7
|
def grabbers
|
8
|
-
%w[Eztv KAT
|
8
|
+
%w[TorrentAPI ThePirateBay Eztv KAT]
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize(default_grabber = nil)
|
12
|
-
|
13
|
-
@g_instances = []
|
14
|
-
reset_tries
|
12
|
+
g_names = grabbers
|
15
13
|
|
16
14
|
# Silently ignores bad names
|
17
|
-
|
18
|
-
|
15
|
+
found_default = g_names.find_index(default_grabber)
|
16
|
+
g_names.rotate! found_default if found_default
|
17
|
+
|
18
|
+
@g_instances = g_names.map { |g| (DownloadTV.const_get g).new }
|
19
|
+
reset_tries
|
19
20
|
|
20
|
-
|
21
|
+
check_grabber_online
|
21
22
|
end
|
22
23
|
|
23
|
-
def
|
24
|
-
if
|
25
|
-
|
26
|
-
|
24
|
+
def check_grabber_online
|
25
|
+
return if @g_instances.first.online?
|
26
|
+
# We won't be using this grabber
|
27
|
+
warn "Problem accessing #{newt.class.name}"
|
28
|
+
@tries -= 1
|
29
|
+
@g_instances.drop 1
|
30
|
+
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
@tries -= 1 # We won't be using this grabber
|
33
|
-
change_grabbers
|
34
|
-
end
|
35
|
-
else # Rotates the instantiated grabbers
|
36
|
-
@g_instances.rotate!
|
37
|
-
end
|
32
|
+
def change_grabbers
|
33
|
+
# Rotates the instantiated grabbers
|
34
|
+
@g_instances.rotate!
|
35
|
+
check_grabber_online
|
38
36
|
end
|
39
37
|
|
40
38
|
def get_links(show)
|
41
39
|
links = @g_instances.first.get_links(show)
|
42
40
|
|
41
|
+
reset_grabbers_order
|
43
42
|
reset_tries
|
44
43
|
|
45
44
|
links
|
@@ -53,6 +52,7 @@ module DownloadTV
|
|
53
52
|
retry
|
54
53
|
|
55
54
|
else
|
55
|
+
reset_grabbers_order
|
56
56
|
reset_tries
|
57
57
|
# Handle show not found here!!
|
58
58
|
return []
|
@@ -60,7 +60,11 @@ module DownloadTV
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def reset_tries
|
63
|
-
@tries = @
|
63
|
+
@tries = @g_instances.size - 1
|
64
|
+
end
|
65
|
+
|
66
|
+
def reset_grabbers_order
|
67
|
+
@g_instances.rotate!(@tries + 1)
|
64
68
|
end
|
65
69
|
end
|
66
70
|
end
|
data/lib/download_tv/version.rb
CHANGED
data/test/torrent_test.rb
CHANGED
@@ -6,14 +6,7 @@ describe DownloadTV::Torrent do
|
|
6
6
|
@t = DownloadTV::Torrent.new
|
7
7
|
end
|
8
8
|
|
9
|
-
it 'will have the right amount of grabbers' do
|
10
|
-
@t.g_names.size.must_equal @t.grabbers.size - 1
|
11
|
-
@t.g_instances.size.must_equal 1
|
12
|
-
end
|
13
|
-
|
14
9
|
it 'will populate the instances' do
|
15
|
-
@t.grabbers.size.times.each { @t.change_grabbers }
|
16
|
-
@t.g_names.empty?.must_equal true
|
17
10
|
@t.g_instances.size.must_equal @t.grabbers.size
|
18
11
|
end
|
19
12
|
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- guille
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.6
|
137
|
+
rubygems_version: 2.7.6
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: DownloadTV is a tool that allows the user to find magnet links for tv show
|