ickabog-ebook/generate.sh

70 lines
2.1 KiB
Bash
Raw Normal View History

2020-05-28 19:43:58 +00:00
#!/bin/bash
HTML_FILE=ickabog.html
echo "<html><head><title>The Ickabog</title></head><body>" > "$HTML_FILE"
2020-06-03 09:58:29 +00:00
function download_chapter() {
if [ ! -f "$2" ]; then
echo "Downloading $2"
wget --quiet "https://www.theickabog.com/$1" -O "$2"
fi
}
download_chapter "king-fred-the-fearless/" "ch1.html"
download_chapter "the-ickabog/" "ch2.html"
download_chapter "death-of-a-seamstress/" "ch3.html"
download_chapter "the-quiet-house/" "ch4.html"
download_chapter "daisy-dovetail/" "ch5.html"
download_chapter "the-fight-in-the-courtyard/" "ch6.html"
download_chapter "lord-spittleworth-tells-tales/" "ch7.html"
download_chapter "the-day-of-petition/" "ch8.html"
download_chapter "the-shepherds-story/" "ch9.html"
download_chapter "king-freds-quest/" "ch10.html"
download_chapter "the-journey-north/" "ch11.html"
download_chapter "the-kings-lost-sword/" "ch12.html"
download_chapter "the-accident/" "ch13.html"
for i in $(seq 1 13); do
2020-05-28 19:43:58 +00:00
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 \
2020-05-29 23:15:28 +00:00
--output=ickabog1.pdf \
2020-05-28 19:43:58 +00:00
--metadata title="The Ickabog" \
--metadata author="J.K Rowling" \
--pdf-engine=xelatex \
--dpi=300 \
-V book \
-V lang=en-US \
2020-05-28 20:04:54 +00:00
-V geometry=margin=1.5cm \
2020-05-28 19:43:58 +00:00
"$HTML_FILE"
2020-05-29 23:15:28 +00:00
pdftk cover.pdf ickabog1.pdf cat output ickabog.pdf
2020-05-28 19:43:58 +00:00
pandoc --from=html --to=epub \
--output=ickabog.epub \
--epub-metadata=metadata.xml \
2020-05-29 23:15:28 +00:00
--epub-cover-image=cover.jpg \
2020-05-28 19:43:58 +00:00
--metadata title="The Ickabog" \
"$HTML_FILE"
2020-05-28 19:59:29 +00:00
pandoc --from=html --to=pdf \
-V fontsize=18pt \
2020-05-29 23:15:28 +00:00
--output=ickabog2.pdf \
2020-05-28 19:59:29 +00:00
--metadata title="The Ickabog" \
--metadata author="J.K Rowling" \
--pdf-engine=context \
-V margin-left=0cm \
-V margin-right=0cm \
-V margin-top=0cm \
-V margin-bottom=0cm \
-V geometry=margin=0cm \
-V lang=en-US \
"$HTML_FILE"
2020-05-29 23:15:28 +00:00
pdftk cover.pdf ickabog2.pdf cat output ickabog-large.pdf