[cmd_import_images][import_src] Added -b option for batchid

This commit is contained in:
ayakael 2018-07-27 05:24:18 -08:00
parent 346cfdc2d1
commit 0e3a0d277c
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026
2 changed files with 7 additions and 3 deletions

View file

@ -6,7 +6,7 @@
# cmd_import_images - Imports CD images into GIT_DIR
#
# USAGE
# cmd_import_images </path/to/image/folder> [<...>]
# cmd_import_images </path/to/git/dir> </path/to/source/dir> -b [<batch-id>] </path/to/image/folder> [<...>]
#
# DEPENDENCIES src/import_images
#
@ -15,6 +15,9 @@
cmd_import_images() {
local GIT_DIR="${1}"
local SOURCE="${2}"; shift 2
case ${1} in
(-b) local BATCHID=${2}; shift 2 ;;
esac
local dirList=("${@}")
@ -54,7 +57,7 @@ cmd_import_images() {
local importList=($(find ${GIT_DIR}/.import/${SOURCE}/ -mindepth 1 -maxdepth 1 -type d -printf '%p\t'))
for import in ${importList[@]}; do
_msg EXEC "Importing ${import}"
import_src "${GIT_DIR}" "${import}" >${STDERR} 2>&1
import_src "${GIT_DIR}" "${import}" $([[ -n "${BATCHID}" ]] && echo "-b") ${BATCHID} >${STDERR} 2>&1
local EXIT=$?
[[ ${EXIT} -eq 0 ]] && _msg OK || _msg WARN "import_src exited with code ${EXIT}"
rm -Rf "${import}" >/dev/null 2>&1

View file

@ -15,6 +15,7 @@
import_src() {
local GIT_DIR="${1}"
local TRACK_DIR="${2}"
[[ ${3} == "-b" ]] && local BATCHID="${4}"
local SOURCE=$(sed 's|.*.import/||' <<<${TRACK_DIR}| cut -d/ -f1)
local supportedsrcList=(FLAC CUETOOLS EAC)
@ -61,7 +62,7 @@ import_src() {
# Conjoins trackmetaList and addmetaList into metadataList
while [[ ${COUNT} -lt ${#trackList[@]} ]]; do
local metadataList[${COUNT}]="${trackmetaList[${COUNT}]};${addmetaList[${COUNT}]};IMAGEID=${IMAGEID};"
local metadataList[${COUNT}]="${trackmetaList[${COUNT}]};${addmetaList[${COUNT}]};IMAGEID=${IMAGEID};BATCHID=${BATCHID}"
local COUNT=$(( ${COUNT} + 1 ))
done