dam/src/deploy_gen

33 lines
1.1 KiB
Text
Raw Normal View History

#!/bin/bash
# doc deploy_gen {
#
# DESCRIPTION
# deploy_gen - Splits specified image into multiple files using a text file
# formatted under the CUE specification
#
# USAGE
# deploy_gen </path/to/git/dir> <IMAGEID>
# }
deploy_gen() {
local GITDIR="${1}"
local IMAGEID="${2}"
## breakpointList generator
# Generates list with cuebreakpoints utility
local breakpointList=($(cuebreakpoints "${GITDIR}/${IMAGEID}.cue" 2>/dev/null))
# In the event that breakpointList is empty because image represents only one track,
# no split occurs, and returns a 0.
[[ -z "${breakpointList[@]}" ]] && { cat "${GITDIR}/${IMAGEID}.flac" > ${GITDIR}/split-track01.flac; return 0; }
# Attempts first split. If fails because of lack of CD quality file, retries with modified breakpointList
if ! printf '%s\n' ${breakpointList[@]} | shntool split "${GITDIR}/${IMAGEID}.flac" -o flac -O always -d "${GITDIR}"; then
printf '%s\n' ${breakpointList[@]} | sed s/$/0/ | shntool split "${GITDIR}/${IMAGEID}.flac" -o flac -O always -d "${GITDIR}"
[[ $? -ne 0 ]] && return 2 || return 1
fi
}