[import_images] Now groks source from function argument rather than through inference; DISCID is now grokked via grep rather than awk; exit code 2 executed when ACCURIP is present on EAC image or is not present on CUETOOLS

This commit is contained in:
ayakael 2018-07-16 05:06:06 -08:00
parent 37266463ce
commit d25f022ced
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026

View file

@ -23,8 +23,9 @@
import_images() {
local GIT_DIR="${1}"
local IMG="${2}"; local pathList[1]="${IMG}"
local CUE="${3}"; local pathList[2]="${CUE}"; shift 3
local SOURCE="${2}"
local IMG="${3}"; local pathList[1]="${IMG}"
local CUE="${4}"; local pathList[2]="${CUE}"; shift 3
while true; do
case ${1} in
(-a) local ACCURIP="${2}"; local pathList[3]="${ACCURIP}"; shift 2;;
@ -34,17 +35,17 @@ import_images() {
esac
done
# Checks if ACCURIP is defined. If so, source CUETOOLS, else, SOURCE is EAC
[[ -z "${ACCURIP}" ]] && local SOURCE=EAC || local SOURCE=CUETOOLS
# Checks if path is valid
for path in ${pathList[@]}; do
[[ -f "${path}" ]] || return 1
done
# Parses cue file for metadata
local METADATA=$(print_meta_cue "${CUE}")
local DISCID="$(awk 'BEGIN{RS=";";FS="="}{if($1=="DISCID"){print $2}}')"
# Checks if ACCURIP should exist or not
if [[ -n "${ACCURIP}" ]] && [[ "${SOURCE}" == "EAC" ]]; then return 2; fi
if [[ -z "${ACCURIP}" ]] && [[ "${SOURCE}" == "CUETOOLS" ]]; then return 2; fi
# Parses cue file for DISCID
local DISCID="$(grep "REM DISCID" ${TRACK_DIR}/cue | cut -d' ' -f3)"
# Copies path to import folder
mkdir -p "${GIT_DIR}/.import/${SOURCE}/$(dirname ${IMG} | sed 's|.*/||')"