2018-03-26 23:34:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-07-11 14:21:52 +00:00
|
|
|
# doc gen_tracks {
|
2018-03-26 23:34:44 +00:00
|
|
|
#
|
|
|
|
# DESCRIPTION
|
2018-07-11 14:21:52 +00:00
|
|
|
# gen_tracks - Splits specified image into multiple files using a text file
|
2018-03-26 23:34:44 +00:00
|
|
|
# formatted under the CUE specification
|
|
|
|
#
|
|
|
|
# USAGE
|
2018-07-11 14:21:52 +00:00
|
|
|
# gen_tracks </path/to/git/dir> </path/to/image> </path/to/cue/file>
|
2018-05-18 20:39:39 +00:00
|
|
|
#
|
2018-03-26 23:34:44 +00:00
|
|
|
# }
|
|
|
|
|
2018-07-11 14:21:52 +00:00
|
|
|
gen_tracks() {
|
2018-03-26 23:34:44 +00:00
|
|
|
local GITDIR="${1}"
|
2018-07-11 14:21:52 +00:00
|
|
|
local IMAGE="${2}"
|
|
|
|
local CUE="${3}"
|
2018-03-26 23:34:44 +00:00
|
|
|
|
|
|
|
## breakpointList generator
|
|
|
|
# Generates list with cuebreakpoints utility
|
2018-07-19 14:18:56 +00:00
|
|
|
local breakpointList=($(print_breakpoints "${CUE}" ))
|
2018-03-26 23:34:44 +00:00
|
|
|
|
|
|
|
# In the event that breakpointList is empty because image represents only one track,
|
|
|
|
# no split occurs, and returns a 0.
|
2018-07-11 14:21:52 +00:00
|
|
|
[[ -z "${breakpointList[@]}" ]] && { cat "${IMAGE}" > ${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-07-19 14:35:51 +00:00
|
|
|
if ! printf '%s\n' ${breakpointList[@]} | shntool split -o flac -O always -d "${GITDIR}" "${IMAGE}" ; then
|
|
|
|
printf '%s\n' ${breakpointList[@]} | sed s/$/0/ | shntool split -o flac -O always -d "${GITDIR}" "${IMAGE}"
|
2018-04-07 22:33:41 +00:00
|
|
|
[[ $? -ne 0 ]] && return 1 || return 0
|
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
|
|
|
}
|
|
|
|
|