diff --git a/scrape.sh b/scrape.sh index 737950d..4fdb07b 100644 --- a/scrape.sh +++ b/scrape.sh @@ -94,7 +94,15 @@ scrape_book() { fi scrape_book_chapter "$chapter" > "$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 title="${chapter%/}" title="${title##*/}"