lib/download_tv/downloader.rb in download_tv-2.5.4 vs lib/download_tv/downloader.rb in download_tv-2.5.5

- old
+ new

@@ -7,18 +7,10 @@ attr_reader :config def initialize(config = {}) @config = Configuration.new(config) # Load configuration - @filters = [ - ->(n) { n.include?('2160p') }, - ->(n) { n.include?('1080p') }, - ->(n) { n.include?('720p') }, - # ->(n) { n.include?('WEB') }, - ->(n) { !n.include?('PROPER') && !n.include?('REPACK') } - ] - Thread.abort_on_exception = true end def download_single_show(show, season = nil) t = Torrent.new(@config.content[:grabber]) @@ -84,11 +76,16 @@ def run_ahead(dont_update_last_run) pending = @config.content[:pending].clone @config.content[:pending].clear pending ||= [] - # Has the program already been run with --tomorrow + # Make normal run first if necessary + if @config.content[:date] < Date.today + pending.concat shows_to_download(@config.content[:date]) + end + + # Only do --tomorrow run if it hasn't happened already if @config.content[:date] < Date.today.next pending.concat today_shows_to_download end if pending.empty? @@ -225,22 +222,15 @@ def fix_names(shows) shows.map { |i| i.gsub(/ \(.+\)|[':]/, '') } end ## - # Iteratively applies filters until they've all been applied - # or applying the next filter would result in no results - # These filters are defined at @filters + # Removes links whose names don't match the user filters + # Runs until no filters are left to be applied or applying + # a filter would leave no results def filter_shows(links) - @filters.each do |f| # Apply each filter - new_links = links.reject { |name, _link| f.call(name) } - # Stop if the filter removes every release - break if new_links.empty? - - links = new_links - end - - links + f = Filterer.new(@config.content[:filters]) + f.filter(links) end ## # Spawns a silent process to download a given magnet link # Uses xdg-open (not portable)