14 lines
876 B
Bash
Executable file
14 lines
876 B
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
cd "$(dirname "$0")"
|
|
curl -sO https://spqrz.gitlab.io/M3GAN-files.epub
|
|
unzip -qo M3GAN-files.epub
|
|
FilesInOrder=$(grep '<content src' toc.ncx | sed 's/[^"]*"//;s/[#"].*//'|uniq)
|
|
# Do not assume the EPUB file boundaries are sensible stopping points;
|
|
# cat them together and re-determine the stopping points.
|
|
cat $FilesInOrder | tr $'\n' ' ' | sed 's/<\([^ >]*\) [^>]*>/<\1>/g;s,</*[^hpeb/][^>]*>,,g;s,<html>[^<]*<head>[^<]*</head>[^<]*<body>,,g;s,</body></html>,,g;s,is legible.</p>,is legible.</p><h3>Rest of chapter (split to fit the 30k limit)</h3>,;s,<em>Aftermath: Cole:</em>,<h4>Aftermath: Cole:</h4>,;s/<h/\n&/g;s/\([12]\)>\n<h/\1><h/g;s/^ *\n//' > one-section-per-line.txt
|
|
# Clean up
|
|
rm -rf epub* co* META* *.css *.ncx titlepage* mimetype
|
|
echo 1 > bookmark.txt
|
|
# Print instructions
|
|
echo "Book initialised. To start reading, run $(dirname "$0")/read"
|