lib/download_tv/downloader.rb in download_tv-2.2.2 vs lib/download_tv/downloader.rb in download_tv-2.3.0
- old
+ new
@@ -2,12 +2,11 @@
##
# Entry point of the application
class Downloader
attr_reader :offset, :config
- def initialize(offset = 0, config = {})
- @offset = offset.abs
+ def initialize(config = {})
@config = Configuration.new(config) # Load configuration
@filters = [
->(n) { n.include?('2160p') },
->(n) { n.include?('1080p') },
@@ -37,12 +36,12 @@
end
##
# Finds download links for all new episodes aired since the last run of the program
# It connects to MyEpisodes in order to find which shows to track and which new episodes aired.
- def run(dont_update_last_run)
- date = check_date
+ def run(dont_update_last_run, offset = 0)
+ date = check_date(offset)
myepisodes = MyEpisodes.new(@config.content[:myepisodes_user], @config.content[:cookie])
# Log in using cookie by default
myepisodes.load_cookie
shows = myepisodes.get_shows(date)
@@ -118,13 +117,13 @@
# Use -1 to skip the download
i == -1 ? '' : links[i][1]
end
end
- def check_date
+ def check_date(offset)
last = @config.content[:date]
- if last - @offset != Date.today
- last - @offset
+ if last - offset != Date.today
+ last - offset
else
puts 'Everything up to date'
exit
end
end