fix illegal chars in title

master
bel 2022-06-27 19:24:55 -06:00
parent 7c06268f8e
commit 69a2003398
1 changed files with 9 additions and 1 deletions

View File

@ -94,7 +94,15 @@ scrape_book() {
fi fi
scrape_book_chapter "$chapter" > "$f" scrape_book_chapter "$chapter" > "$f"
log scraping book title from $f log scraping book title from $f
local title="$(grep '^\#' "$f" | head -n 1 | sed 's/^\#*//' | sed 's/^[ ]*//' | sed 's/[ ]*$//')" local title="$(
grep '^\#' "$f" \
| head -n 1 \
| sed 's/^\#*//' \
| sed 's/^[ ]*//' \
| sed 's/[ ]*$//' \
| sed 's/[ ][ ]*/ /g' \
| sed 's/[^a-zA-Z0-9]/_/g' \
)"
if [ -z "$title" ]; then if [ -z "$title" ]; then
title="${chapter%/}" title="${chapter%/}"
title="${title##*/}" title="${title##*/}"