Last active
January 9, 2024 08:29
-
-
Save ivan/efe09fde99bf551e5882ff0c59b7f883 to your computer and use it in GitHub Desktop.
unbook-all-inputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
set -eu -o pipefail | |
# Enable job control for wait-until-jobs-below | |
set -m | |
wait-until-jobs-below () { | |
while test $(jobs | wc -l) -ge "$1"; do | |
sleep 0.1 | |
done | |
} | |
for i in ~/unbook-input/**/*.{epub,mobi,azw,azw3,lit,chm}; do | |
echo $i | |
out=${i/\/unbook-input\//\/unbook-output\/}.html | |
log=${i/\/unbook-input\//\/unbook-logs\/}.log | |
mkdir -p "$(dirname -- "$out")" "$(dirname -- "$log")" | |
(nice unbook -f -o "$out" --replace-serif-and-sans-serif always --replace-monospace always --base-font-family 'InterDisplay, sans-serif' --append-head '<link rel="stylesheet" href="https://rsms.me/inter/inter.css">' --csp-style-src https://rsms.me/inter/ --csp-font-src https://rsms.me/inter/ "$i" 2> "$log") & | |
wait-until-jobs-below 18 | |
done | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment