💾 Archived View for alpha.lyk.so › systems › e-reader › scripts › ebook-from-web.sh captured on 2021-11-30 at 20:18:30.
-=-=-=-=-=-=-
#!/usr/bin/env sh # Dependencies: # calibre set -e EBOOK_DIR="$HOME/extramuros/documents/ebooks" [ "$2" ] || { >&2 echo "usage: $0 <author> <URL> [formats]"; exit 1; } temp="$(mktemp -d)" trap 'rm -fr "$temp"' EXIT INT HUP web2disk -r0 -d "$temp" "$2" fname="$(basename "$2")" formats="${3:-epub,mobi}" # Mobi is compatible with old Kindles mkdir -p "$EBOOK_DIR/$1" echo "$formats" | tr , "\n" | while read format; do dest="$EBOOK_DIR/$1/${fname%.*}.$format" ebook-convert "$temp/"*.xhtml "$dest" ebook-meta -a "$(echo "$1" | sed 's/ and / & /')" --identifier "uri:$2" "$dest" done echo "Done!"