lib/download_tv/downloader.rb in download_tv-2.5.0 vs lib/download_tv/downloader.rb in download_tv-2.5.1
- old
+ new
@@ -31,11 +31,11 @@
# it tries to find download links for each
def download_from_file(filename)
if File.exist? filename
filename = File.realpath(filename)
t = Torrent.new(@config.content[:grabber])
- to_download = File.readlines(filename, chomp:true)
+ to_download = File.readlines(filename, chomp: true)
fix_names(to_download).each { |show| download(get_link(t, show)) }
else
puts "Error: #{filename} not found"
exit 1
end
@@ -45,15 +45,15 @@
# 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, offset = 0)
- pending = @config.content[:pending]
+ pending = @config.content[:pending].clone
@config.content[:pending].clear
pending ||= []
date = check_date(offset)
- if pending.empty? and date.nil?
+ if pending.empty? && date.nil?
puts 'Everything up to date'
exit
end
to_download = shows_to_download(date)
@@ -61,11 +61,11 @@
if to_download.empty?
puts 'Nothing to download'
else
- t = Torrent.new()
+ t = Torrent.new
queue = Queue.new
# Adds a link (or empty string to the queue)
link_t = Thread.new do
@@ -114,16 +114,16 @@
# Uses a Torrent object to obtain links to the given tv show
# When :auto is true it will try to find the best match
# based on a set of filters.
# When it's false it will prompt the user to select the preferred result
# Returns either a magnet link or an emptry string
- def get_link(torrent, show, save_pending=false)
+ def get_link(torrent, show, save_pending = false)
links = torrent.get_links(show)
if links.empty?
@config.content[:pending] << show if save_pending
- return ''
+ return ''
end
if @config.content[:auto]
links = filter_shows(links)
links.first[1]
@@ -154,13 +154,12 @@
##
# Returns the date from which to check for shows
# Or nil if the date is today
def check_date(offset)
last = @config.content[:date]
- if last - offset != Date.today
- last - offset
- end
+ last -= offset
+ last if last != Date.today
end
##
# Given a list of shows and episodes:
#
@@ -169,10 +168,9 @@
shows.reject do |i|
# Remove season+episode
@config.content[:ignored]
.include?(i.split(' ')[0..-2].join(' ').downcase)
end
-
end
##
# Given a list of shows and episodes:
#