download_tv 2.6.1 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +35 -0
- data/README.md +3 -4
- data/bin/tv +2 -6
- data/lib/download_tv/configuration.rb +18 -18
- data/lib/download_tv/downloader.rb +40 -67
- data/lib/download_tv/myepisodes.rb +2 -2
- data/lib/download_tv/version.rb +1 -1
- data/test/config_test.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29c9837fef84c38a41063a8526525e12ce56c82bd8c8467289401dd8ae5453ba
|
|
4
|
+
data.tar.gz: c448ce24115b3cb19dcc128c56a47cdee61d072994dafcfe5ab3d53b5d799109
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a00092c93cc8076bf41d2a43a198f16be217ef251f74586387f92303e2db9baf0db8008f09271a7f086788578368dec2a881429136caf0d9c71d4fc2ff00be22
|
|
7
|
+
data.tar.gz: b79f9e1625c27bd2c3f2c6c33b8092dcd0c1fb8c29a4e0f950619d0484d20d7fa175398e5d9e67cc6e8e7c268f137715e3c7e04e1c5c1e323c45d436a084eb4c
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
+
# They are provided by a third-party and are governed by
|
|
3
|
+
# separate terms of service, privacy policy, and support
|
|
4
|
+
# documentation.
|
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
+
|
|
8
|
+
name: Ruby
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
branches: [ master ]
|
|
13
|
+
pull_request:
|
|
14
|
+
branches: [ master ]
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
test:
|
|
18
|
+
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
strategy:
|
|
21
|
+
matrix:
|
|
22
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v2
|
|
26
|
+
- 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
|
|
31
|
+
with:
|
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: bundle exec rake
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# download_tv
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
4
|
[](https://badge.fury.io/rb/download_tv)
|
|
5
5
|
[](https://codeclimate.com/github/guille/download_tv)
|
|
6
6
|
|
|
@@ -21,18 +21,17 @@ Specific options:
|
|
|
21
21
|
-o, --offset OFFSET Move back the last run offset
|
|
22
22
|
-f, --file PATH Download shows from a file
|
|
23
23
|
-d, --download SHOW Downloads given show
|
|
24
|
-
|
|
24
|
+
-s, --season SEASON Limit the show download to a specific season
|
|
25
25
|
-t, --tomorrow Download shows airing today
|
|
26
26
|
-c, --configure Configures defaults
|
|
27
27
|
--show-config Show current configuration values
|
|
28
28
|
--dry-run Don't write to the date file
|
|
29
29
|
-a, --[no-]auto Automatically find links
|
|
30
|
-
-s, --[no-]subtitles Download subtitles
|
|
31
30
|
-g, --grabber GRABBER Use given grabber as first option
|
|
32
31
|
--show-grabbers List available grabbers
|
|
33
32
|
-p, --pending Show list of pending downloads
|
|
34
33
|
--clear-pending Clear list of pending downloads
|
|
35
|
-
-q, --queue
|
|
34
|
+
-q, --queue SHOW Add show episode to pending downloads list
|
|
36
35
|
-v, --version Print version
|
|
37
36
|
-h, --help Show this message
|
|
38
37
|
```
|
data/bin/tv
CHANGED
|
@@ -30,7 +30,7 @@ opt_parser = OptionParser.new do |opts|
|
|
|
30
30
|
options[:arg] = s
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
opts.on('--season SEASON', 'Limit the show download to a specific season') do |s|
|
|
33
|
+
opts.on('-s', '--season SEASON', 'Limit the show download to a specific season') do |s|
|
|
34
34
|
options[:cmd] = 'dl'
|
|
35
35
|
options[:season] = s
|
|
36
36
|
end
|
|
@@ -55,10 +55,6 @@ opt_parser = OptionParser.new do |opts|
|
|
|
55
55
|
config[:auto] = n
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
opts.on('-s', '--[no-]subtitles', 'Download subtitles') do |n|
|
|
59
|
-
config[:subs] = n
|
|
60
|
-
end
|
|
61
|
-
|
|
62
58
|
opts.on('-g', '--grabber GRABBER', 'Use given grabber as first option') do |g|
|
|
63
59
|
config[:grabber] = g
|
|
64
60
|
end
|
|
@@ -117,7 +113,7 @@ begin
|
|
|
117
113
|
dl.download_from_file(options[:arg])
|
|
118
114
|
when 'tomorrow'
|
|
119
115
|
dl = DownloadTV::Downloader.new(config)
|
|
120
|
-
dl.
|
|
116
|
+
dl.run(options[:dry], options[:offset].abs, include_tomorrow: true)
|
|
121
117
|
when 'config'
|
|
122
118
|
DownloadTV::Configuration.new(config, true)
|
|
123
119
|
when 'showconfig'
|
|
@@ -26,7 +26,7 @@ module DownloadTV
|
|
|
26
26
|
prompt_for_cookie
|
|
27
27
|
prompt_for_ignored
|
|
28
28
|
prompt_for_filters
|
|
29
|
-
|
|
29
|
+
$stdout.flush
|
|
30
30
|
|
|
31
31
|
set_default_values
|
|
32
32
|
serialize
|
|
@@ -38,13 +38,13 @@ module DownloadTV
|
|
|
38
38
|
else
|
|
39
39
|
print 'Enter your MyEpisodes username: '
|
|
40
40
|
end
|
|
41
|
-
input =
|
|
41
|
+
input = $stdin.gets.chomp
|
|
42
42
|
@content[:myepisodes_user] = input if input
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def prompt_for_cookie
|
|
46
46
|
print 'Save cookie? (y)/n: '
|
|
47
|
-
@content[:cookie] = !(
|
|
47
|
+
@content[:cookie] = !($stdin.gets.chomp.casecmp? 'n')
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def prompt_for_ignored
|
|
@@ -54,11 +54,11 @@ module DownloadTV
|
|
|
54
54
|
puts 'Enter a comma-separated list of shows to ignore: '
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
@content[:ignored] =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
@content[:ignored] = $stdin.gets
|
|
58
|
+
.chomp
|
|
59
|
+
.split(',')
|
|
60
|
+
.map(&:strip)
|
|
61
|
+
.map(&:downcase)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def prompt_for_filters
|
|
@@ -68,19 +68,19 @@ module DownloadTV
|
|
|
68
68
|
|
|
69
69
|
puts 'Enter a comma-separated list of terms to include: '
|
|
70
70
|
|
|
71
|
-
@content[:filters][:includes] =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
@content[:filters][:includes] = $stdin.gets
|
|
72
|
+
.chomp
|
|
73
|
+
.split(',')
|
|
74
|
+
.map(&:strip)
|
|
75
|
+
.map(&:upcase)
|
|
76
76
|
|
|
77
77
|
puts 'Enter a comma-separated list of terms to exclude: '
|
|
78
78
|
|
|
79
|
-
@content[:filters][:excludes] =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
@content[:filters][:excludes] = $stdin.gets
|
|
80
|
+
.chomp
|
|
81
|
+
.split(',')
|
|
82
|
+
.map(&:strip)
|
|
83
|
+
.map(&:upcase)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def default_filters
|
|
@@ -12,19 +12,26 @@ module DownloadTV
|
|
|
12
12
|
Thread.abort_on_exception = true
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
##
|
|
16
|
+
# Tries to download episodes in order for a given season,
|
|
17
|
+
# until it can't find any
|
|
18
|
+
def download_entire_season(show, season)
|
|
19
|
+
season.insert(0, '0') if season.size == 1
|
|
20
|
+
episode = "#{show} s#{season}e01"
|
|
21
|
+
loop do
|
|
22
|
+
link = get_link(t, episode)
|
|
23
|
+
break if link.empty?
|
|
24
|
+
|
|
25
|
+
download(link)
|
|
26
|
+
episode = episode.next
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
15
30
|
def download_single_show(show, season = nil)
|
|
16
31
|
t = Torrent.new(@config.content[:grabber])
|
|
17
32
|
show = fix_names([show]).first
|
|
18
33
|
if season
|
|
19
|
-
|
|
20
|
-
episode = "#{show} s#{season}e01"
|
|
21
|
-
loop do
|
|
22
|
-
link = get_link(t, episode)
|
|
23
|
-
break if link.empty?
|
|
24
|
-
|
|
25
|
-
download(link)
|
|
26
|
-
episode = episode.next
|
|
27
|
-
end
|
|
34
|
+
download_entire_season(show, season)
|
|
28
35
|
else
|
|
29
36
|
download(get_link(t, show))
|
|
30
37
|
end
|
|
@@ -45,58 +52,45 @@ module DownloadTV
|
|
|
45
52
|
end
|
|
46
53
|
end
|
|
47
54
|
|
|
55
|
+
##
|
|
56
|
+
# Returns the date from which to check shows
|
|
57
|
+
def date_to_check_from(offset)
|
|
58
|
+
return @config.content[:date] if offset.zero?
|
|
59
|
+
|
|
60
|
+
Date.today - offset
|
|
61
|
+
end
|
|
62
|
+
|
|
48
63
|
##
|
|
49
64
|
# Finds download links for all new episodes aired since
|
|
50
65
|
# the last run of the program
|
|
51
66
|
# It connects to MyEpisodes in order to find which shows
|
|
52
67
|
# to track and which new episodes aired.
|
|
53
|
-
|
|
68
|
+
# The param +dont_update_last_run+ prevents changing the configuration's date value
|
|
69
|
+
# The param +offset+ can be used to move the date back that many days in the check
|
|
70
|
+
# The param +include_tomorrow+ will add the current day to the list of dates to search
|
|
71
|
+
def run(dont_update_last_run, offset = 0, include_tomorrow: false)
|
|
54
72
|
pending = @config.content[:pending].clone
|
|
55
73
|
@config.content[:pending].clear
|
|
56
74
|
pending ||= []
|
|
57
|
-
date =
|
|
75
|
+
date = date_to_check_from(offset)
|
|
58
76
|
|
|
59
|
-
pending.concat shows_to_download(date) if date
|
|
77
|
+
pending.concat shows_to_download(date) if date < Date.today
|
|
78
|
+
pending.concat today_shows_to_download if include_tomorrow && date < Date.today.next
|
|
60
79
|
|
|
61
80
|
if pending.empty?
|
|
62
81
|
puts 'Nothing to download'
|
|
63
82
|
else
|
|
64
|
-
find_and_download(pending)
|
|
83
|
+
find_and_download(pending.uniq)
|
|
65
84
|
puts 'Completed. Exiting...'
|
|
66
85
|
end
|
|
67
86
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
##
|
|
75
|
-
# Finds download links for all the episodes set to air today.
|
|
76
|
-
# TODO: Refactor with #run()
|
|
77
|
-
def run_ahead(dont_update_last_run)
|
|
78
|
-
pending = @config.content[:pending].clone
|
|
79
|
-
@config.content[:pending].clear
|
|
80
|
-
pending ||= []
|
|
81
|
-
|
|
82
|
-
# Make normal run first if necessary
|
|
83
|
-
if @config.content[:date] < Date.today
|
|
84
|
-
pending.concat shows_to_download(@config.content[:date])
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Only do --tomorrow run if it hasn't happened already
|
|
88
|
-
if @config.content[:date] < Date.today.next
|
|
89
|
-
pending.concat today_shows_to_download
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
if pending.empty?
|
|
93
|
-
puts 'Nothing to download'
|
|
94
|
-
else
|
|
95
|
-
find_and_download(pending)
|
|
96
|
-
puts 'Completed. Exiting...'
|
|
87
|
+
unless dont_update_last_run
|
|
88
|
+
@config.content[:date] = if include_tomorrow
|
|
89
|
+
Date.today.next
|
|
90
|
+
else
|
|
91
|
+
[Date.today, @config.content[:date]].max
|
|
92
|
+
end
|
|
97
93
|
end
|
|
98
|
-
|
|
99
|
-
@config.content[:date] = Date.today.next unless dont_update_last_run
|
|
100
94
|
@config.serialize
|
|
101
95
|
rescue InvalidLoginError
|
|
102
96
|
warn 'Wrong username/password combination'
|
|
@@ -108,7 +102,7 @@ module DownloadTV
|
|
|
108
102
|
|
|
109
103
|
# Adds a link (or empty string to the queue)
|
|
110
104
|
link_t = Thread.new do
|
|
111
|
-
shows.each { |show| queue << get_link(t, show, true) }
|
|
105
|
+
shows.each { |show| queue << get_link(t, show, save_pending: true) }
|
|
112
106
|
end
|
|
113
107
|
|
|
114
108
|
# Downloads the links as they are added
|
|
@@ -121,20 +115,13 @@ module DownloadTV
|
|
|
121
115
|
end
|
|
122
116
|
end
|
|
123
117
|
|
|
124
|
-
# Downloading the subtitles
|
|
125
|
-
# subs_t = @config.content[:subs] and Thread.new do
|
|
126
|
-
# shows.each { |show| @s.get_subs(show) }
|
|
127
|
-
# end
|
|
128
|
-
|
|
129
118
|
link_t.join
|
|
130
119
|
download_t.join
|
|
131
|
-
# subs_t.join
|
|
132
120
|
end
|
|
133
121
|
|
|
134
122
|
def shows_to_download(date)
|
|
135
123
|
myepisodes = MyEpisodes.new(@config.content[:myepisodes_user],
|
|
136
124
|
@config.content[:cookie])
|
|
137
|
-
# Log in using cookie by default
|
|
138
125
|
myepisodes.load_cookie
|
|
139
126
|
shows = myepisodes.get_shows_since(date)
|
|
140
127
|
shows = reject_ignored(shows)
|
|
@@ -156,7 +143,7 @@ module DownloadTV
|
|
|
156
143
|
# based on a set of filters.
|
|
157
144
|
# When it's false it will prompt the user to select the preferred result
|
|
158
145
|
# Returns either a magnet link or an emptry string
|
|
159
|
-
def get_link(torrent, show, save_pending
|
|
146
|
+
def get_link(torrent, show, save_pending: false)
|
|
160
147
|
links = torrent.get_links(show)
|
|
161
148
|
|
|
162
149
|
if links.empty?
|
|
@@ -191,19 +178,6 @@ module DownloadTV
|
|
|
191
178
|
print 'Select the torrent you want to download [-1 to skip]: '
|
|
192
179
|
end
|
|
193
180
|
|
|
194
|
-
##
|
|
195
|
-
# Returns the date from which to check shows
|
|
196
|
-
# or nil if the program was already ran today
|
|
197
|
-
# Passing an offset skips this check
|
|
198
|
-
def check_date(offset)
|
|
199
|
-
if offset.zero?
|
|
200
|
-
last = @config.content[:date]
|
|
201
|
-
last if last < Date.today
|
|
202
|
-
else
|
|
203
|
-
Date.today - offset
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
181
|
##
|
|
208
182
|
# Given a list of shows and episodes:
|
|
209
183
|
#
|
|
@@ -235,7 +209,6 @@ module DownloadTV
|
|
|
235
209
|
|
|
236
210
|
##
|
|
237
211
|
# Spawns a silent process to download a given magnet link
|
|
238
|
-
# Uses xdg-open (not portable)
|
|
239
212
|
def download(link)
|
|
240
213
|
@cmd ||= detect_os
|
|
241
214
|
|
|
@@ -32,11 +32,11 @@ module DownloadTV
|
|
|
32
32
|
def prompt_user_data
|
|
33
33
|
if !@user || @user == ''
|
|
34
34
|
print 'Enter your MyEpisodes username: '
|
|
35
|
-
@user =
|
|
35
|
+
@user = $stdin.gets.chomp
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
print 'Enter your MyEpisodes password: '
|
|
39
|
-
pass =
|
|
39
|
+
pass = $stdin.noecho(&:gets).chomp
|
|
40
40
|
puts
|
|
41
41
|
pass
|
|
42
42
|
end
|
data/lib/download_tv/version.rb
CHANGED
data/test/config_test.rb
CHANGED
|
@@ -48,7 +48,7 @@ describe DownloadTV::Configuration do
|
|
|
48
48
|
create_dummy_config(config_path)
|
|
49
49
|
|
|
50
50
|
c = DownloadTV::Configuration.new(path: config_path)
|
|
51
|
-
c.breaking_changes?(DownloadTV::VERSION).must_be_nil
|
|
51
|
+
_(c.breaking_changes?(DownloadTV::VERSION)).must_be_nil
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
it "returns true when there's been a major update" do
|
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.
|
|
4
|
+
version: 2.6.2
|
|
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: 2021-05-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -116,6 +116,7 @@ executables:
|
|
|
116
116
|
extensions: []
|
|
117
117
|
extra_rdoc_files: []
|
|
118
118
|
files:
|
|
119
|
+
- ".github/workflows/ruby.yml"
|
|
119
120
|
- ".gitignore"
|
|
120
121
|
- ".travis.yml"
|
|
121
122
|
- Gemfile
|
|
@@ -162,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
162
163
|
- !ruby/object:Gem::Version
|
|
163
164
|
version: '0'
|
|
164
165
|
requirements: []
|
|
165
|
-
rubygems_version: 3.
|
|
166
|
+
rubygems_version: 3.2.17
|
|
166
167
|
signing_key:
|
|
167
168
|
specification_version: 4
|
|
168
169
|
summary: DownloadTV is a tool that allows the user to find magnet links for tv show
|