[import_src] Will now return 2 if SOURCE is not supported; changed other exit codes to accomodate; SOURCE is now grokked from .import subfolder

This commit is contained in:
ayakael 2018-07-16 04:52:20 -08:00
parent d3a11f2f18
commit eaf7fb4389
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026

View file

@ -15,11 +15,13 @@
import_src() { import_src() {
local GIT_DIR="${1}" local GIT_DIR="${1}"
local TRACK_DIR="${2}" local TRACK_DIR="${2}"
local SOURCE=$(basename "${2}") local SOURCE=$(sed 's|.*.import/||' <<<${TRACK_DIR}| cut -d/ -f1)
local supportedsrcList=$(FLAC CUETOOLS EAC) local supportedsrcList=(FLAC CUETOOLS EAC)
echo ${TRACK_DIR}
# Checks if source supported # Checks if source supported
if ! _if_array_contains ${SOURCE} ${supportedsrcList[@]}; then return 1; fi if ! _if_array_contains ${SOURCE} ${supportedsrcList[@]}; then return 1; fi
[[ ! -d "${TRACK_DIR}" ]] && return 2
local trackList=($(find ${TRACK_DIR} -maxdepth 1 -name '*.flac' -printf '%p\n' | sort)) local trackList=($(find ${TRACK_DIR} -maxdepth 1 -name '*.flac' -printf '%p\n' | sort))
@ -28,7 +30,7 @@ import_src() {
echo "Processing audio files" echo "Processing audio files"
gen_image "${TRACK_DIR}/flac" $(printf "%s\t" ${trackList[@]}) > ${STDERR} 2>&1 gen_image "${TRACK_DIR}/flac" $(printf "%s\t" ${trackList[@]}) > ${STDERR} 2>&1
local EXIT="$?" local EXIT="$?"
[[ $? -eq 0 ]] || return 2 [[ $? -eq 0 ]] || return 3
# Generates IMAGEID # Generates IMAGEID
@ -55,14 +57,14 @@ import_src() {
echo "Generating cue file" echo "Generating cue file"
gen_cue "${TRACK_DIR}" $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.cue" gen_cue "${TRACK_DIR}" $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.cue"
local EXIT=$? local EXIT=$?
[[ $? -eq 0 ]] || return 3 [[ $? -eq 0 ]] || return 4
add_bom "${GIT_DIR}/${IMAGEID}.cue" add_bom "${GIT_DIR}/${IMAGEID}.cue"
# Generate tags file # Generate tags file
_msg EXEC "Generating tags file" _msg EXEC "Generating tags file"
gen_mtag $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.tags" gen_mtag $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.tags"
local EXIT=$? local EXIT=$?
[[ $? -eq 0 ]] || return 4 [[ $? -eq 0 ]] || return 5
add_bom "${GIT_DIR}/${IMAGEID}.tags" add_bom "${GIT_DIR}/${IMAGEID}.tags"