From 20ecbdb3ae6cb29ea6072e7700cbb1f357273bdc Mon Sep 17 00:00:00 2001 From: Nemo Date: Fri, 29 May 2020 01:13:58 +0530 Subject: [PATCH] Initial commit --- .gitignore | 3 +++ README.md | 23 +++++++++++++++++++++++ generate.sh | 38 ++++++++++++++++++++++++++++++++++++++ metadata.xml | 4 ++++ 4 files changed, 68 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100755 generate.sh create mode 100644 metadata.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b040e2e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.html +*.epub +*.pdf diff --git a/README.md b/README.md new file mode 100644 index 0000000..9588e25 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# ickabog-ebook + +Generates ebooks for The Ickabog by J.K Rowling. Original text from https://www.theickabog.com/home/ + +## Dependencies: + +- `wget` +- [`pup`](https://github.com/ericchiang/pup) +- [`pandoc`](https://pandoc.org/) + +## How to run + +`./generate.sh` + +You should have `ickabog.epub`, and `ickabog.pdf` in your directory after the script finishes. + +## Cover + +Currently no cover is available. If you'd like to submit a cover for this book, please let me know. I think a kid-drawn illustration would be perfect, keeping with the theme of the contest. + +## License + +Licensed under the [MIT License](https://nemo.mit-license.org/). See LICENSE file for details. diff --git a/generate.sh b/generate.sh new file mode 100755 index 0000000..3a5e16e --- /dev/null +++ b/generate.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +HTML_FILE=ickabog.html +echo "The Ickabog" > "$HTML_FILE" +wget https://www.theickabog.com/king-fred-the-fearless/ -O ch1.html +wget https://www.theickabog.com/the-ickabog/ -O ch2.html +wget https://www.theickabog.com/death-of-a-seamstress/ -O ch3.html +wget https://www.theickabog.com/the-quiet-house/ -O ch4.html +wget https://www.theickabog.com/daisy-dovetail/ -O ch5.html +wget https://www.theickabog.com/the-fight-in-the-courtyard/ -O ch6.html +wget https://www.theickabog.com/lord-spittleworth-tells-tales/ -O ch7.html +wget https://www.theickabog.com/the-day-of-petition/ -O ch8.html + +for i in $(seq 1 8); do + CHAPTER_TITLE=$(cat "ch$i.html" | pup 'h1.entry-title:nth-child(2) text{}') + echo "

$CHAPTER_TITLE

" >> "$HTML_FILE" + cat "ch$i.html" | pup 'article div.row:nth-child(2) div.entry-content' >> "$HTML_FILE" +done + +echo "" >> "$HTML_FILE" + +pandoc --from=html --to=pdf \ + --output=ickabog.pdf \ + --metadata title="The Ickabog" \ + --metadata author="J.K Rowling" \ + --pdf-engine=xelatex \ + --dpi=300 \ + -V book \ + -V lang=en-US \ + -V geometry=margin=3cm \ + --columns=60 \ + "$HTML_FILE" + +pandoc --from=html --to=epub \ + --output=ickabog.epub \ + --epub-metadata=metadata.xml \ + --metadata title="The Ickabog" \ + "$HTML_FILE" diff --git a/metadata.xml b/metadata.xml new file mode 100644 index 0000000..8028220 --- /dev/null +++ b/metadata.xml @@ -0,0 +1,4 @@ +The Ickabog +2020-05-20 +en-US +The Ickabog