diff --git a/split2flac b/split2flac index f0a9ed2..b7c008c 100755 --- a/split2flac +++ b/split2flac @@ -275,6 +275,22 @@ update_pattern () { update_pattern_aux "$v" "_${tag_name}" $(echo "${tag_value}" | sed "s/ /_/g") } +check_cuetools () { + if ! which cuebreakpoints 2>/dev/null ; then + emsg "'cuebreakpoints' tool was not found, " + emsg "you should install 'cuetools' package\n" + exit 1 + fi +} + +check_shntool () { + if ! which shnsplit 2>/dev/null ; then + emsg "'shnsplit' tool was not found, " + emsg "you should install 'shntool' package\n" + exit 1 + fi +} + # splits a file split_file () { TMPCUE="${HOME}/.split2flac_XXXXX.cue" @@ -423,6 +439,8 @@ split_file () { TAG_ALBUM=$(${GETTAG} %T "${CUE}" 2>/dev/null) TRACKS_NUM=$(${GETTAG} %N "${CUE}" 2>/dev/null) + check_cuetools + # some cue sheets may have non-audio tracks # we can check the difference between what cuebreakpoints and cueprint gives us BREAKPOINTS_NUM=$(($(cuebreakpoints "${CUE}" 2>/dev/null | wc -l) + 1)) @@ -502,6 +520,8 @@ split_file () { *) emsg "Unknown output format ${FORMAT}\n"; exit 1;; esac + check_shntool + # split to tracks # sed expression is a fix for "shnsplit: error: m:ss.ff format can only be used with CD-quality files" cuebreakpoints "${CUE}" 2>/dev/null | \