2018-03-26 23:34:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# doc deploy_gen {
|
|
|
|
#
|
|
|
|
# DESCRIPTION
|
|
|
|
# deploy_gen - Splits specified image into multiple files using a text file
|
|
|
|
# formatted under the CUE specification
|
|
|
|
#
|
|
|
|
# USAGE
|
2018-03-28 13:52:57 +00:00
|
|
|
# deploy_gen </path/to/git/dir> <IMAGEID>
|
2018-03-26 23:34:44 +00:00
|
|
|
# }
|
|
|
|
|
|
|
|
deploy_gen() {
|
|
|
|
local GITDIR="${1}"
|
2018-03-28 13:52:57 +00:00
|
|
|
local IMAGEID="${2}"
|
2018-03-26 23:34:44 +00:00
|
|
|
|
|
|
|
## 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.
|
2018-03-28 13:52:57 +00:00
|
|
|
[[ -z "${breakpointList[@]}" ]] && { cat "${GITDIR}/${IMAGEID}.flac" > ${GITDIR}/split-track01.flac; return 0; }
|
2018-03-26 23:34:44 +00:00
|
|
|
|
|
|
|
# Attempts first split. If fails because of lack of CD quality file, retries with modified breakpointList
|
2018-03-28 13:52:57 +00:00
|
|
|
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
|
2018-03-26 23:34:44 +00:00
|
|
|
fi
|
2018-03-28 13:52:57 +00:00
|
|
|
|
2018-03-26 23:34:44 +00:00
|
|
|
}
|
|
|
|
|