diff --git a/book_search_preview.sh b/book_search_preview.sh index 06449f6..5c14966 100755 --- a/book_search_preview.sh +++ b/book_search_preview.sh @@ -1,11 +1,36 @@ #!/bin/bash +############################################################################## +# +# books_search_preview.sh +# By Steven Saus +# (c) 2024; licensed under the MIT license +# +############################################################################### + Instring="$@" ID=$(echo "${Instring}" | awk '{print $1}') -#Command=$(echo "$Instring" | sed 's/ (/./g' | sed 's/)//g' | sed 's/:man:/:man -Pcat:/g' | awk -F ':' '{print $2 " " $1}') -# install unhtml from pacakage manager -if [ -f $(which unhtml) ];then - calibredb show_metadata "${ID}" | unhtml + +# if the first bit is an ID, I'm assuming it's from calibredb and in that format +# otherwise, it's my "old" filename-based format, which would still be useful if +# you are NOT using Calibre, but are using something else to manage your library +# but have tagged your ebooks. +# + +if [ "$ID" -eq "$ID" ] 2>/dev/null +then + # install unhtml from pacakage manager + if [ -f $(which unhtml) ];then + calibredb show_metadata "${ID}" | unhtml + else + calibredb show_metadata "${ID}" + fi else - calibredb show_metadata "${ID}" + # xargs to trim whitespace + FILENAME=$(echo "${Instring}" | awk -F '|' '{print $4}' | xargs ) + if [ -f $(which unhtml) ];then + exiftool "${FILENAME}" | unhtml + else + exiftool "${FILENAME}" + fi fi