2020-05-28 19:43:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-04 07:47:40 +00:00
|
|
|
mkdir -p html
|
|
|
|
|
2020-05-28 19:43:58 +00:00
|
|
|
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() {
|
2020-06-04 07:47:40 +00:00
|
|
|
[ -s "html/$2.html" ] || wget --quiet "https://www.theickabog.com/$1" -O "html/$2.html"
|
2020-06-03 09:58:29 +00:00
|
|
|
}
|
|
|
|
|
2020-06-09 08:22:39 +00:00
|
|
|
download_chapter king-fred-the-fearless/ ch1
|
|
|
|
download_chapter the-ickabog/ ch2
|
|
|
|
download_chapter death-of-a-seamstress/ ch3
|
|
|
|
download_chapter the-quiet-house/ ch4
|
|
|
|
download_chapter daisy-dovetail/ ch5
|
|
|
|
download_chapter the-fight-in-the-courtyard/ ch6
|
|
|
|
download_chapter lord-spittleworth-tells-tales/ ch7
|
|
|
|
download_chapter the-day-of-petition/ ch8
|
|
|
|
download_chapter the-shepherds-story/ ch9
|
|
|
|
download_chapter king-freds-quest/ ch10
|
|
|
|
download_chapter the-journey-north/ ch11
|
|
|
|
download_chapter the-kings-lost-sword/ ch12
|
|
|
|
download_chapter the-accident/ ch13
|
|
|
|
download_chapter lord-spittleworths-plan/ ch14
|
|
|
|
download_chapter the-king-returns/ ch15
|
2020-06-05 20:52:21 +00:00
|
|
|
download_chapter bert-says-goodbye/ ch16
|
|
|
|
download_chapter goodfellow-makes-a-stand/ ch17
|
|
|
|
download_chapter end-of-an-advisor/ ch18
|
|
|
|
download_chapter lady-eslanda/ ch19
|
2020-06-09 08:22:39 +00:00
|
|
|
download_chapter medals-for-beamish-and-buttons/ ch20
|
|
|
|
download_chapter professor-fraudysham/ ch21
|
2020-06-03 09:58:29 +00:00
|
|
|
|
2020-06-05 20:52:21 +00:00
|
|
|
|
2020-06-09 08:22:39 +00:00
|
|
|
for i in $(seq 1 21); do
|
2020-06-04 07:47:40 +00:00
|
|
|
CHAPTER_TITLE=$(cat "html/ch$i.html" | pup 'h1.entry-title:nth-child(2) text{}')
|
2020-05-28 19:43:58 +00:00
|
|
|
echo "<h2>$CHAPTER_TITLE</h2>" >> "$HTML_FILE"
|
2020-06-04 07:47:40 +00:00
|
|
|
cat "html/ch$i.html" | pup 'article div.row:nth-child(2) div.entry-content' >> "$HTML_FILE"
|
2020-05-28 19:43:58 +00:00
|
|
|
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
|