diff --git a/.gitignore b/.gitignore index 03b0b5d..db2bff2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ /oathbringer/*.html /wok-prime/*.html /edgedancer/*.html +/oathbringer-reread/*.html /books/* +vendor diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..22b0b6b --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +# frozen_string_literal: true +source "https://rubygems.org" + +gem 'nokogiri' +gem 'paru' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..1f400f4 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,17 @@ +GEM + remote: https://rubygems.org/ + specs: + mini_portile2 (2.3.0) + nokogiri (1.8.4) + mini_portile2 (~> 2.3.0) + paru (0.3.0.1) + +PLATFORMS + ruby + +DEPENDENCIES + nokogiri + paru + +BUNDLED WITH + 1.16.3 diff --git a/README.md b/README.md index 91aaf44..82bbd6e 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,12 @@ Scripts to generate books from the [Cosmere]() using various public sources. Currently supports the following books: -1. Oathbringer (Serialized till Chapter 32) -2. Way of Kings Reread -3. Words of Radiance Reread -4. Edgedancer Reread -5. Way of Kings Prime +1. Oathbringer (Serialized till Chapter 32) +2. Way of Kings Reread +3. Words of Radiance Reread +4. Edgedancer Reread +5. Way of Kings Prime +6. Oathbringer Reread For obvious reasons, the converted ebooks are not part of this repo. You must download and run the script on your own machine to generate the copies. @@ -45,12 +46,18 @@ More details at https://www.tor.com/series/edgedancer-reread-brandon-sanderson/ ## Way of Kings: Prime ->For it([Altered Perceptions anthology](https://www.indiegogo.com/projects/altered-perceptions)), I’m letting people see—for the first time—a large chunk of the original version of The Way of Kings, which I wrote in 2002–2003. This version is very different, and involves a different course in life for Kaladin as a character—all due to a simple decision he makes one way in this book, but a completely different way in the published novel. +> For it([Altered Perceptions anthology](https://www.indiegogo.com/projects/altered-perceptions)), I’m letting people see—for the first time—a large chunk of the original version of The Way of Kings, which I wrote in 2002–2003. This version is very different, and involves a different course in life for Kaladin as a character—all due to a simple decision he makes one way in this book, but a completely different way in the published novel. ->These chapters are quite fun, as I consider what happened in The Way of Kings Prime (as I now call it) to be an "alternate reality" version of the events in the published books. The characters are almost all exactly the same people, but their backstories are different, and that has transformed who they are and how they react to the world around them. Roshar is similar, yet wildly different, as this was before I brought in the spren as a major world element. +> These chapters are quite fun, as I consider what happened in The Way of Kings Prime (as I now call it) to be an "alternate reality" version of the events in the published books. The characters are almost all exactly the same people, but their backstories are different, and that has transformed who they are and how they react to the world around them. Roshar is similar, yet wildly different, as this was before I brought in the spren as a major world element. You can read more at the announcement at [BrandonSanderson.com](https://brandonsanderson.com/chapters-from-the-original-draft-of-the-way-of-kings-available-in-anthology-to-benefit-robison-wells/) +# Oathbringer Reread + +> Join Alice Arneson and Lyndsey Luther for a reread of Brandon Sanderson’s Oathbringer, the third novel in the Stormlight Archive epic fantasy series. + +More details at https://www.tor.com/series/oathbringer-reread-brandon-sanderson/ + ## Requirements - Ruby @@ -106,6 +113,12 @@ All the generated files will be saved with the filename `books/edgedancer-reread All the generated files will be saved with the filename `books/wok-prime.{epub|pdf|mobi|html}`. This generation might take a while the script attempts to strip out unnecessary HTML. +## Oathbringer Reread + + ruby oathbringer-reread.rb + +All the generated files will be saved with the filename `books/oathbringer-reread.{epub|pdf|mobi|html}`. This generation might take a while the script attempts to strip out unnecessary HTML. + ## Extra If you'd like to see any other books covered here, please create an issue, or reach out to me: diff --git a/covers/oathbringer-reread.jpg b/covers/oathbringer-reread.jpg new file mode 100644 index 0000000..52d0b31 Binary files /dev/null and b/covers/oathbringer-reread.jpg differ diff --git a/covers/oathbringer-reread.pdf b/covers/oathbringer-reread.pdf new file mode 100644 index 0000000..2544218 Binary files /dev/null and b/covers/oathbringer-reread.pdf differ diff --git a/metadata/oathbringer-reread.xml b/metadata/oathbringer-reread.xml new file mode 100644 index 0000000..007cf22 --- /dev/null +++ b/metadata/oathbringer-reread.xml @@ -0,0 +1,5 @@ +Oathbringer Reread +2018-07-26 +en-US +Alice Arneson +Lyndsey Luther diff --git a/oathbringer-reread.rb b/oathbringer-reread.rb new file mode 100644 index 0000000..afe053b --- /dev/null +++ b/oathbringer-reread.rb @@ -0,0 +1,73 @@ +require 'date' +require 'fileutils' +require 'nokogiri' +require_relative './methods' + +FileUtils.mkdir_p('oathbringer-reread') + +BASE = 'https://www.tor.com'.freeze + +links = [ + "/2018/01/25/introducing-the-oathbringer-reread/", + "/2018/02/01/oathbringer-reread-prologue/", + "/2018/02/08/oathbringer-reread-chapter-one/", + "/2018/02/15/oathbringer-reread-chapter-two/", + "/2018/02/22/oathbringer-reread-chapter-three/", + "/2018/03/01/oathbringer-reread-chapter-four/", + "/2018/03/08/oathbringer-reread-chapters-five-and-six/", + "/2018/03/15/oathbringer-reread-chapter-seven/", + "/2018/03/22/oathbringer-reread-chapters-eight-and-nine/", + "/2018/03/29/oathbringer-reread-chapter-ten/", + "/2018/04/05/oathbringer-reread-chapter-eleven/", + "/2018/04/12/oathbringer-reread-chapter-12/", + "/2018/04/19/oathbringer-reread-chapter-thirteen/", + "/2018/04/26/oathbringer-reread-chapters-fourteen-and-fifteen/", + "/2018/05/03/oathbringer-reread-chapter-16/", + "/2018/05/10/oathbringer-reread-chapter-seventeen/", + "/2018/05/17/oathbringer-reread-chapter-eighteen/", + "/2018/05/24/oathbringer-reread-chapters-19-and-20-brandon-sanderson/", + "/2018/05/31/oathbringer-reread-chapters-twenty-one-and-twenty-two/", + "/2018/06/07/oathbringer-reread-chapters-twenty-three-and-twenty-four/", + "/2018/06/14/oathbringer-reread-chapter-twenty-five/", + "/2018/06/21/oathbringer-reread-chapters-twenty-six-and-twenty-seven/", + "/2018/06/28/oathbringer-reread-chapter-twenty-eight/", + "/2018/07/05/oathbringer-reread-chapters-twenty-nine-and-thirty/", + "/2018/07/12/oathbringer-reread-chapters-thirty-one-and-thirty-two/", + "/2018/07/19/oathbringer-reread-interludes-one-two-and-three/", + "/2018/07/26/oathbringer-reread-chapter-thirty-three/" +] + +episode = 1 + +links.each do |link| + url = BASE + link + puts "Download #{url}" + unless File.exist? "wor/#{episode}.html" + `wget --no-clobber "#{url}" --output-document "oathbringer-reread/#{episode}.html" -o /dev/null` + end + episode += 1 +end + +# Now we have all the files +html = '' +for i in 1..(links.length) + complete_html = Nokogiri::HTML(open("oathbringer-reread/#{i}.html")) + page = complete_html.css('.entry-content') + title = complete_html.css('.entry-title>a').inner_html + ending = false + page.children.each do |e| + ending = true if e.class?('squib') || e.class?('post-end-spacer') + e.remove if ending + end + html += "

#{title}

" + html += page.inner_html + + url = BASE + links[i - 1] + + html += "

Visit tor.com for discussion.

" +end + +File.open('books/oathbringer-reread.html', 'w') { |file| file.write(html) } +puts '[html] Generated HTML file' + +generate('oathbringer-reread', :all)