fi
BASE_DIR="$AONDIR/common/epub"
-book_db="$AONDIR/common/sqlite/bookcodes.db"
for book in $@
do
- row=($(sqlite3 -separator ' ' $book_db "select lang, series from bookcodes where book = '$book';"))
+ row=( $($AONDIR/common/scripts/list-book-info.sh $book) )
- lang=${row[0]}
- series=${row[1]}
+ lang=${row[1]}
+ series=${row[2]}
source_dir="$BASE_DIR/$book"
exit 1
fi
-book_db="$AONDIR/common/sqlite/bookcodes.db"
-
for book in $@
do
- row=($(sqlite3 -separator ' ' $book_db "select lang, series from bookcodes where book = '$book';"))
+ row=( $($AONDIR/common/scripts/list-book-info.sh $book) )
- lang=${row[0]}
- series=${row[1]}
+ lang=${row[1]}
+ series=${row[2]}
source_dir="$AONDIR/$lang/svg/$series"
output_dir="$CURR_DIR/$lang/svg/$series"
exit 1
fi
-book_db="$AONDIR/common/sqlite/bookcodes.db"
-
for book in $@
do
- row=($(sqlite3 -separator ' ' $book_db "select lang, series from bookcodes where book = '$book';"))
+ row=( $($AONDIR/common/scripts/list-book-info.sh $book) )
- lang=${row[0]}
- series=${row[1]}
+ lang=${row[1]}
+ series=${row[2]}
for format in xhtml xhtml-less-simple
do
--- /dev/null
+#!/usr/bin/env bash
+#
+# List all book into that match given bookcode(s). If the bookcode is omitted,
+# outputs data for all books.
+#
+# Examples:
+# list-book-info.sh lw gs
+#
+# list-book-info.sh
+
+if [ ! -d "$AONDIR" ]; then
+ >&2 echo "Please set the AONDIR environment variable"
+ exit 1
+fi
+
+book_db="$AONDIR/common/sqlite/bookcodes.db"
+
+if [ -z "$1" ]; then
+ sqlite3 -column -noheader "$book_db" <<EOF
+ select book, lang, series
+ from bookcodes
+ order by book
+EOF
+ exit
+fi
+
+
+for book in $@
+do
+ if [[ ! $book =~ ^[a-z0-9]+[a-z]$ ]]; then
+ >&2 echo "invalid book code"
+ exit
+ fi
+
+ sqlite3 -column -noheader "$book_db" <<EOF
+ select book, lang, series
+ from bookcodes
+ where book = '$book'
+ order by book
+EOF
+done