Adds Rhythm of War
This commit is contained in:
parent
99dad3f997
commit
6f7a9cef76
|
@ -2,6 +2,7 @@
|
|||
/wor/*.html
|
||||
/skyward/*.html
|
||||
/oathbringer/*.html
|
||||
/row/*.html
|
||||
/wok-prime/*.html
|
||||
/edgedancer/*.html
|
||||
/oathbringer-reread/*.html
|
||||
|
|
|
@ -24,8 +24,6 @@ You can download sample files (Lorem Ipsum) from <http://ge.tt/8R61oXm2> to see
|
|||
|
||||
Tor.com is publishing Oathbringer in serialized form till Chapter 32. This script downloads all of these posts and converts them into a publishable format, including epub, mobi, pdf and html. You can find the tor.com announcement at https://www.tor.com/2017/08/15/brandon-sanderson-oathbringer-serialization-announcement/.
|
||||
|
||||
The script figures out all the chapter URLs, so I just run it every Tuesday now (it doesn't need updates).
|
||||
|
||||
## Way of Kings Reread
|
||||
|
||||
Join Michael Pye (aka The Mad Hatter) and Carl Engle-Laird as they dive into the details of Sanderson’s complex new world of Roshar.
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 78 KiB |
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
<!-- <dc:identifier id="epub-id-1" opf:scheme="ISBN-10">076532637X</dc:identifier> -->
|
||||
<!-- <dc:identifier id="epub-id-2" opf:scheme="ISBN-13">978-0765326379</dc:identifier> -->
|
||||
<dc:title id="epub-title-1">Rhythm of War: Book Four of the Stormlight Archive</dc:title>
|
||||
<dc:date>2020-11-17</dc:date>
|
||||
<dc:language>en-US</dc:language>
|
||||
<dc:creator id="epub-creator-1" opf:role="aut">Brandon Sanderson</dc:creator>
|
|
@ -0,0 +1,69 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'date'
|
||||
require 'fileutils'
|
||||
require 'nokogiri'
|
||||
require_relative './methods'
|
||||
FileUtils.mkdir_p('row')
|
||||
|
||||
BASE = 'https://www.tor.com/2020/'
|
||||
|
||||
links = [
|
||||
'07/23/read-rhythm-of-war-by-brandon-sanderson-prologue-and-chapter-one/',
|
||||
'07/28/read-rhythm-of-war-by-brandon-sanderson-chapters-two-and-three/',
|
||||
'08/04/read-rhythm-of-war-by-brandon-sanderson-chapters-four-and-five/'
|
||||
]
|
||||
|
||||
# Automatically adds all recent chapters
|
||||
puts 'Downloading all found links'
|
||||
chapter = 5
|
||||
next_date = Date.new(1970, 1, 1)
|
||||
loop do
|
||||
links.last.split('/')
|
||||
month = links.last.split('/').first
|
||||
day = links.last.split('/')[1]
|
||||
next_date = Date.new(2020, month.to_i, day.to_i) + 7
|
||||
break if next_date > Date.today
|
||||
ending_chapter = [chapter + 2, 32].min
|
||||
links << "#{next_date.strftime('%m')}/#{next_date.strftime('%d')}/read-rhythm-of-war-by-brandon-sanderson-chapters-#{chapter}-#{ending_chapter}/"
|
||||
chapter += 3
|
||||
break if next_date + 7 > Date.today
|
||||
end
|
||||
next_date += 7
|
||||
|
||||
episode = 1
|
||||
|
||||
links.each do |link|
|
||||
url = BASE + link
|
||||
puts "Download #{url}"
|
||||
unless File.exist? "row/#{episode}.html"
|
||||
`wget --no-clobber "#{url}" --output-document "row/#{episode}.html" -o /dev/null`
|
||||
end
|
||||
episode += 1
|
||||
end
|
||||
|
||||
# Now we have all the files
|
||||
html = ''
|
||||
for i in 1..(links.length)
|
||||
page = Nokogiri::HTML(open("row/#{i}.html")).css('.entry-content')
|
||||
start = ending = false
|
||||
page.children.each do |e|
|
||||
if e.name == 'h3'
|
||||
e.name = 'h1'
|
||||
start = true
|
||||
end
|
||||
|
||||
ending = true if e.class?('frontmatter') && start
|
||||
|
||||
e.remove if !start || ending
|
||||
end
|
||||
html += page.inner_html
|
||||
url = BASE + links[i - 1]
|
||||
end
|
||||
|
||||
html += "<p>Next 3 chapters out on #{next_date}</p>"
|
||||
|
||||
File.open('books/row.html', 'w') { |file| file.write(html) }
|
||||
puts '[html] Generated HTML file'
|
||||
|
||||
generate('row', :all)
|
Loading…
Reference in New Issue