From 31c3b39b68676e8a2addbc23d97229057233b11d Mon Sep 17 00:00:00 2001 From: ayakael Date: Wed, 11 Jul 2018 06:21:52 -0800 Subject: [PATCH] [export_gen] Changed name to gen_tracks to relativize [gen_tracks] Relativized function [export_cp][export_cp][gen_trackid] Changed name of export_gen function, and update to support new syntax --- src/export_cp | 4 ++-- src/export_mv | 2 +- src/gen_trackid | 9 +++++---- src/{export_gen => gen_tracks} | 19 ++++++++++--------- 4 files changed, 18 insertions(+), 16 deletions(-) rename src/{export_gen => gen_tracks} (56%) diff --git a/src/export_cp b/src/export_cp index a471ea7..f555519 100644 --- a/src/export_cp +++ b/src/export_cp @@ -9,7 +9,7 @@ # USAGE # export_cp # -# DEPENDENCIES bunc/src/* src/export_gen src/export_mv +# DEPENDENCIES bunc/src/* src/gen_tracks src/export_mv # # } @@ -23,7 +23,7 @@ export_cp() { ## Splits IMAGEID into TRACKIDs _msg EXEC "Splitting ${IMAGEID}" - export_gen "${GIT_DIR}" ${IMAGEID} >${STDERR} 2>&1 + gen_tracks "${GIT_DIR}" "${GIT_DIR}/${IMAGEID}.flac" "${GIT_DIR}/${IMAGEID}.cue" >${STDERR} 2>&1 [[ $? -ne 0 ]] && _msg WARN export_mv "${GIT_DIR}" ${IMAGEID} >${STDERR} 2>&1 [[ $? -eq 0 ]] && _msg OK || _msg WARN diff --git a/src/export_mv b/src/export_mv index 8efa1dc..1c3eedd 100644 --- a/src/export_mv +++ b/src/export_mv @@ -3,7 +3,7 @@ # doc export_mv { # # DESCRIPTION -# export_mv - Renames output files from export_gen to associated TRACKID +# export_mv - Renames output files from gen_tracks to associated TRACKID # # USAGE # export_mv # -# DEPENDENCIES src/export_gen +# DEPENDENCIES src/gen_tracks # # } gen_trackid() { - FLAC="${1}" - CUE="${2}" + GIT_DIR="${1}" + FLAC="${2}" + CUE="${3}" - export_gen ${FLAC} ${CUE} >/dev/null 2>&1 + gen_tracks "${GIT_DIR}" "${FLAC}" "${CUE}" >/dev/null 2>&1 local TOTALTRACKS="$(grep -e "TRACK [0-9][0-9] AUDIO" "${CUE}" | wc -l)" local COUNT=1 diff --git a/src/export_gen b/src/gen_tracks similarity index 56% rename from src/export_gen rename to src/gen_tracks index 10baae7..7184e27 100644 --- a/src/export_gen +++ b/src/gen_tracks @@ -1,31 +1,32 @@ #!/bin/bash -# doc export_gen { +# doc gen_tracks { # # DESCRIPTION -# export_gen - Splits specified image into multiple files using a text file +# gen_tracks - Splits specified image into multiple files using a text file # formatted under the CUE specification # # USAGE -# export_gen +# gen_tracks # # } -export_gen() { +gen_tracks() { local GITDIR="${1}" - local IMAGEID="${2}" + local IMAGE="${2}" + local CUE="${3}" ## breakpointList generator # Generates list with cuebreakpoints utility - local breakpointList=($(cuebreakpoints "${GITDIR}/${IMAGEID}.cue" 2>/dev/null)) + local breakpointList=($(cuebreakpoints "${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; } + [[ -z "${breakpointList[@]}" ]] && { cat "${IMAGE}" > ${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 -o flac -O always -d "${GITDIR}" "${GITDIR}/${IMAGEID}.flac" ; then - printf '%s\n' ${breakpointList[@]} | sed s/$/0/ | shntool split -o flac -O always -d "${GITDIR}" "${GITDIR}/${IMAGEID}.flac" + if ! printf '%s\n' ${breakpointList[@]} | shntool split -o flac -O always -d "${GITDIR}" "${IMAGE}.flac" ; then + printf '%s\n' ${breakpointList[@]} | sed s/$/0/ | shntool split -o flac -O always -d "${GITDIR}" "${IMAGE}.flac" [[ $? -ne 0 ]] && return 1 || return 0 fi