Initial commit

This commit is contained in:
Nemo 2020-05-29 01:13:58 +05:30
commit 20ecbdb3ae
4 changed files with 68 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.html
*.epub
*.pdf

23
README.md Normal file
View File

@ -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.

38
generate.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
HTML_FILE=ickabog.html
echo "<html><head><title>The Ickabog</title></head><body>" > "$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 "<h2>$CHAPTER_TITLE</h2>" >> "$HTML_FILE"
cat "ch$i.html" | pup 'article div.row:nth-child(2) div.entry-content' >> "$HTML_FILE"
done
echo "</body></html>" >> "$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"

4
metadata.xml Normal file
View File

@ -0,0 +1,4 @@
<dc:title id="epub-title-1">The Ickabog</dc:title>
<dc:date>2020-05-20</dc:date>
<dc:language>en-US</dc:language>
<dc:creator id="epub-creator-1" opf:role="aut">The Ickabog</dc:creator>