download_tv 2.5.4 → 2.5.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: 14480f4df75d1bd924641e70896710bdbaadbd61e7cdc2988c802f094c5841e1
4
- data.tar.gz: cdee66d0f1c699e56b2b48c3376d4654ded93d17d6ea5851acf79e728e1b792e
3
+ metadata.gz: 4054ab9c742ef1b4a8966b4a8e0f6adfb124142da744827e034e39574b2bc1e4
4
+ data.tar.gz: 947049650860802c48eb0adcea1299caf1416e10cd5c1fab0a27d2f553dfb4f7
5
5
  SHA512:
6
- metadata.gz: e65a989bc27f5741d656ea853f660fc50e2c2fd46fcb03794e50afd03f47b698b354d73845b940b03f6809d31cd5bf84108627ebb09410bb76c924cc36964730
7
- data.tar.gz: 27afaf52a2aa2c699d7f95333aefcb8c3c622e3c9b2a1e1cce801fb9705f4f5824d9e16a5e6b01585960f9f0f3b4fd464e64e5ecafab2b5ed6e2ed9242e9e897
6
+ metadata.gz: 4e723e145e18922ee3bea26ac69db06c94c55e87f80059041c51486648469014c54fc1e1e08a77f369d3a85d04abe1e8b0958613b13d395f2d074188ed4190f1
7
+ data.tar.gz: 2943f772dee6e8bb4a18c8086af317dc450e3453ff5dbef17886dc33442e0fd78aadc28928a218b3bdc9067d95f12e6af64f5144a82f5ca75c91625782456654
data/README.md CHANGED
@@ -42,11 +42,13 @@ By default, download_tv connects to your MyEpisodes.com account and fetches the
42
42
 
43
43
  The -o flag can be used in order to re-download the episodes from previous days. The --dry-run option is useful to prevent download_tv from updating the date (for example, when running the application shortly after an episode airs).
44
44
 
45
+ Starting in version 2.5.4, download_tv includes the --tomorrow flag. By default, an execution of download_tv will download shows airing from the last execution of the program up to a day prior to the current day. Use this flag to include shows airing today in this search. This can be useful depending on your timezone or on the airtime of the shows you follow.
46
+
45
47
  **Note**: Due to API limitations, the gem won't find shows aired more than 14 days prior to the execution of the script.
46
48
 
47
49
  The options -c and --show-config allow the user to change or view the current configuration values, respectively. These options include your myepisodes username, whether to save cookies or ask for password on each run and the list of ignored shows among other things. The configuration files are (mostly) backwards compatible. The gem will force you to change your configuration after an update if there are breaking changes in it.
48
50
 
49
- 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).
51
+ 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 (see Section Filters).
50
52
 
51
53
  ### Single torrent download
52
54
 
@@ -70,6 +72,14 @@ I usually publish a patch update to the gem when I detect one of them isn't work
70
72
 
71
73
  download_tv version 2.5.0 persists the list of shows it can't find on a given execution (when connecting to MyEpisodes, not for single show or file downloads) and it will try to find them again on following executions. This list can be viewed by passing the -p flag to the tv binary. The list can be cleared with the --clear-pending option.
72
74
 
75
+ ### Filters
76
+
77
+ download_tv version 2.5.5 adds the possibility of setting include/exclude filters for the automatic download of shows.
78
+
79
+ Up until that version, the filters by default were excluding 1080p or 720p, as well as including PROPER or REPACK releases when available. From that version onwards, the user can specify in their configuration (`tv -c`) a list of words to include or exclude from their results.
80
+
81
+ Please keep in mind that this is not a hard filter. The application will apply as many user-defined filters as possible **while still returning at least one result**.
82
+
73
83
  ### License
74
84
 
75
- This project is released under the terms of the MIT license. See [LICENSE.md](https://github.com/guille/download_tv/blob/master/LICENSE.md) file for details.
85
+ This project is released under the terms of the MIT license. See [LICENSE.md](https://github.com/guille/download_tv/blob/master/LICENSE.md) file for details.
data/download_tv.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.executables = ['tv']
24
24
 
25
- s.add_development_dependency 'bundler', '~> 1.15'
25
+ s.add_development_dependency 'bundler', '~> 2.0'
26
26
  s.add_development_dependency 'minitest', '~> 5.0'
27
27
  s.add_development_dependency 'rake', '~> 10.0'
28
28
 
data/lib/download_tv.rb CHANGED
@@ -11,6 +11,7 @@ require 'download_tv/version'
11
11
  require 'download_tv/configuration'
12
12
  require 'download_tv/downloader'
13
13
  require 'download_tv/torrent'
14
+ require 'download_tv/filterer'
14
15
  require 'download_tv/myepisodes'
15
16
  require 'download_tv/linkgrabber'
16
17
  require 'download_tv/subtitles'
@@ -25,6 +25,7 @@ module DownloadTV
25
25
  prompt_for_myep_user
26
26
  prompt_for_cookie
27
27
  prompt_for_ignored
28
+ prompt_for_filters
28
29
  STDOUT.flush
29
30
 
30
31
  set_default_values
@@ -37,7 +38,8 @@ module DownloadTV
37
38
  else
38
39
  print 'Enter your MyEpisodes username: '
39
40
  end
40
- @content[:myepisodes_user] = STDIN.gets.chomp
41
+ input = STDIN.gets.chomp
42
+ @content[:myepisodes_user] = input if input
41
43
  end
42
44
 
43
45
  def prompt_for_cookie
@@ -59,6 +61,35 @@ module DownloadTV
59
61
  .map(&:downcase)
60
62
  end
61
63
 
64
+ def prompt_for_filters
65
+ puts "Current filters: (#{@content[:filters]})" if @content[:filters]
66
+
67
+ @content[:filters] = {}
68
+
69
+ puts 'Enter a comma-separated list of terms to include: '
70
+
71
+ @content[:filters][:includes] = STDIN.gets
72
+ .chomp
73
+ .split(',')
74
+ .map(&:strip)
75
+ .map(&:upcase)
76
+
77
+ puts 'Enter a comma-separated list of terms to exclude: '
78
+
79
+ @content[:filters][:excludes] = STDIN.gets
80
+ .chomp
81
+ .split(',')
82
+ .map(&:strip)
83
+ .map(&:upcase)
84
+ end
85
+
86
+ def default_filters
87
+ {
88
+ 'includes' => %w[PROPER REPACK],
89
+ 'excludes' => %w[2160P 1080P 720P]
90
+ }
91
+ end
92
+
62
93
  def set_default_values
63
94
  # When modifying existing config, keeps previous values
64
95
  # When creating new one, sets defaults
@@ -66,6 +97,7 @@ module DownloadTV
66
97
  @content[:subs] ||= true
67
98
  @content[:grabber] ||= 'TorrentAPI'
68
99
  @content[:date] ||= Date.today - 1
100
+ @content[:filters] ||= default_filters
69
101
  @content[:pending] ||= []
70
102
  @content[:version] = DownloadTV::VERSION
71
103
  end
@@ -9,14 +9,6 @@ module DownloadTV
9
9
  def initialize(config = {})
10
10
  @config = Configuration.new(config) # Load configuration
11
11
 
12
- @filters = [
13
- ->(n) { n.include?('2160p') },
14
- ->(n) { n.include?('1080p') },
15
- ->(n) { n.include?('720p') },
16
- # ->(n) { n.include?('WEB') },
17
- ->(n) { !n.include?('PROPER') && !n.include?('REPACK') }
18
- ]
19
-
20
12
  Thread.abort_on_exception = true
21
13
  end
22
14
 
@@ -86,7 +78,12 @@ module DownloadTV
86
78
  @config.content[:pending].clear
87
79
  pending ||= []
88
80
 
89
- # Has the program already been run with --tomorrow
81
+ # Make normal run first if necessary
82
+ if @config.content[:date] < Date.today
83
+ pending.concat shows_to_download(@config.content[:date])
84
+ end
85
+
86
+ # Only do --tomorrow run if it hasn't happened already
90
87
  if @config.content[:date] < Date.today.next
91
88
  pending.concat today_shows_to_download
92
89
  end
@@ -227,19 +224,12 @@ module DownloadTV
227
224
  end
228
225
 
229
226
  ##
230
- # Iteratively applies filters until they've all been applied
231
- # or applying the next filter would result in no results
232
- # These filters are defined at @filters
227
+ # Removes links whose names don't match the user filters
228
+ # Runs until no filters are left to be applied or applying
229
+ # a filter would leave no results
233
230
  def filter_shows(links)
234
- @filters.each do |f| # Apply each filter
235
- new_links = links.reject { |name, _link| f.call(name) }
236
- # Stop if the filter removes every release
237
- break if new_links.empty?
238
-
239
- links = new_links
240
- end
241
-
242
- links
231
+ f = Filterer.new(@config.content[:filters])
232
+ f.filter(links)
243
233
  end
244
234
 
245
235
  ##
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DownloadTV
4
+ ##
5
+ # Builds and applies filters to the results
6
+ class Filterer
7
+ attr_reader :filters
8
+
9
+ def initialize(filters_config)
10
+ @filters = []
11
+ build_filters(filters_config)
12
+ end
13
+
14
+ def build_include_filter(str)
15
+ @filters << ->(n) { !n.upcase.include?(str) }
16
+ end
17
+
18
+ def build_exclude_filter(str)
19
+ @filters << ->(n) { n.upcase.include?(str) }
20
+ end
21
+
22
+ def build_filters(filters_config)
23
+ return unless filters_config
24
+
25
+ filters_config[:includes].map { |i| build_include_filter(i) }
26
+ filters_config[:excludes].map { |i| build_exclude_filter(i) }
27
+ end
28
+
29
+ ##
30
+ # Iteratively applies filters until they've all been applied
31
+ # or applying the next filter would result in no results
32
+ def filter(shows)
33
+ # shows is tuple (show name, link)
34
+ @filters.each do |f|
35
+ new_shows = shows.reject { |name, _link| f.call(name) }
36
+ # Go to next filter if the filter removes every release
37
+ next if new_shows.empty?
38
+
39
+ shows = new_shows
40
+ end
41
+
42
+ shows
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.5.4'
4
+ VERSION = '2.5.5'
5
5
  end
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.5.4
4
+ version: 2.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - guille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-19 00:00:00.000000000 Z
11
+ date: 2019-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.15'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.15'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +99,7 @@ files:
99
99
  - lib/download_tv.rb
100
100
  - lib/download_tv/configuration.rb
101
101
  - lib/download_tv/downloader.rb
102
+ - lib/download_tv/filterer.rb
102
103
  - lib/download_tv/grabbers/addic7ed.rb
103
104
  - lib/download_tv/grabbers/eztv.rb
104
105
  - lib/download_tv/grabbers/kat.rb
@@ -133,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  - !ruby/object:Gem::Version
134
135
  version: '0'
135
136
  requirements: []
136
- rubyforge_project:
137
- rubygems_version: 2.7.7
137
+ rubygems_version: 3.0.1
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