automatically gets all chapters

Automatically downloads all chapters that's been released so far. Doesn't take time zones into account
This commit is contained in:
MikaelBergquist 2017-09-21 00:47:08 +02:00
parent 226b2a8695
commit 768f72e67b
1 changed files with 27 additions and 8 deletions

View File

@ -9,17 +9,36 @@ BASE = 'https://www.tor.com/2017/'.freeze
links = [
'08/22/oathbringer-brandon-sanderson-prologue/',
'08/29/oathbringer-brandon-sanderson-chapter-1-3/',
'09/05/oathbringer-by-brandon-sanderson-chapters-4-6/',
'09/12/oathbringer-by-brandon-sanderson-chapters-7-9/'
'09/05/oathbringer-by-brandon-sanderson-chapters-4-6/'
]
links.last.split('/')
month = links.last.split('/').first
day = links.last.split('/')[1]
next_date = Date.new(2017, month.to_i, day.to_i) + 7
manually_add_links = false;
if manually_add_links
# Only downloads links already added to array <links>
puts 'Downloading manually added links'
links.last.split('/')
month = links.last.split('/').first
day = links.last.split('/')[1]
next_date = Date.new(2017, month.to_i, day.to_i) + 7
else
# Automatically adds all recent chapters
puts 'Downloading all found links'
chapter = Integer(links.last.split('-').last.gsub(/[^0-9]/, '')) + 1
puts chapter
next_date = Date.new(1970,01,01)
loop do
links.last.split('/')
month = links.last.split('/').first
day = links.last.split('/')[1]
next_date = Date.new(2017, month.to_i, day.to_i) + 7
links << "#{next_date.strftime("%m")}/#{next_date.strftime("%d")}/oathbringer-by-brandon-sanderson-chapters-#{chapter}-#{chapter + 2}/"
chapter += 3;
puts next_date
break if next_date + 7 > Date.today
end
end
next_date += 7;
episode = 1
links.each do |link|