Adds code for Mythwalker

This commit is contained in:
Nemo 2020-08-15 12:53:19 +05:30
parent 67b03e15c4
commit afc3286fa7
6 changed files with 69 additions and 0 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@
vendor
darkone/
*.cbz
/mythwalker/*.html

BIN
covers/mythwalker-blank.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

BIN
covers/mythwalker.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

BIN
covers/mythwalker.pdf Normal file

Binary file not shown.

4
metadata/mythwalker.xml Normal file
View File

@ -0,0 +1,4 @@
<dc:title id="epub-title-1">Warbreaker Prime: Mythwalker</dc:title>
<dc:date>2019-11-22</dc:date>
<dc:language>en-US</dc:language>
<dc:creator id="epub-creator-1" opf:role="aut">Brandon Sanderson</dc:creator>

64
mythwalker.rb Normal file
View File

@ -0,0 +1,64 @@
# frozen_string_literal: true
require 'date'
require 'fileutils'
require 'nokogiri'
require_relative './methods'
FileUtils.mkdir_p('mythwalker')
BASE = 'https://brandonsanderson.com'
links = [
"/warbreaker-prime-mythwalker-prologue/",
"/warbreaker-prime-mythwalker-chapter-one/",
"/warbreaker-prime-mythwalker-chapter-two/",
"/warbreaker-prime-mythwalker-chapter-three/",
"/warbreaker-prime-mythwalker-chapter-four/",
"/warbreaker-prime-mythwalker-chapter-five/",
"/warbreaker-prime-mythwalker-chapter-six/",
"/warbreaker-prime-mythwalker-chapter-seven/",
"/warbreaker-prime-mythwalker-chapter-eight/",
"/warbreaker-prime-mythwalker-chapter-nine/",
"/warbreaker-prime-mythwalker-chapter-ten/",
"/warbreaker-prime-mythwalker-chapter-eleven/",
"/warbreaker-prime-mythwalker-chapter-twelve/",
"/warbreaker-prime-mythwalker-chapter-thirteen/",
"/warbreaker-prime-mythwalker-chapter-fourteen/",
"/warbreaker-prime-mythwalker-chapter-fifteen/",
"/warbreaker-prime-mythwalker-chapter-sixteen/",
"/warbreaker-prime-mythwalker-chapter-seventeen/",
"/warbreaker-prime-mythwalker-chapter-eighteen/",
"/warbreaker-prime-mythwalker-chapter-nineteen/",
"/warbreaker-prime-mythwalker-chapter-twenty/",
"/warbreaker-prime-mythwalker-chapter-twenty-one/",
"/warbreaker-prime-mythwalker-chapter-twenty-two/",
"/warbreaker-deleted-scenes-mab-the-cook/",
]
titles = ["Prologue"] + (1..22).map{|x| "Chapter #{x}"} + ["Deleted Scenes: Mab the Cook"]
episode=1
links.each do |link|
url = BASE + link
puts "Download #{url}"
unless File.exist? "mythwalker/#{episode}.html"
`wget --no-clobber "#{url}" --output-document "mythwalker/#{episode}.html" -o /dev/null`
end
episode+=1
end
html = '<html lang=en><head><title>Warbreaker Prime: Mythwalker</title></head><body>'
(1..(links.length)).each do |i|
complete_html = Nokogiri::HTML(open("mythwalker/#{i}.html"))
page = complete_html.css('.vc_col-sm-7 .wpb_wrapper')[0]
html += "<h1>#{titles[i - 1]}</h1>" + page.inner_html
end
html += '</body></html>'
File.open('books/mythwalker.html', 'w') { |file| file.write(html) }
puts '[html] Generated HTML file'
generate('mythwalker', :all)