[import_dir] Renamed to import_src
[import_src] Moved error handling to exit codes [import_src] SOURCE var is now defined by last subfolder [import_src] Now checks if SOURCE is supported
This commit is contained in:
parent
8bc2cb41a3
commit
e025acf4d1
1 changed files with 17 additions and 12 deletions
|
@ -1,38 +1,43 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# doc import_dir {
|
# doc import_src {
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# import_dir - Imports consolidated tracks into git repository
|
# import_src - Imports source into git directory
|
||||||
#
|
#
|
||||||
# USAGE
|
# USAGE
|
||||||
# import_dir </path/to/git/dir> </path/to/track/dir>
|
# import_src </path/to/git/dir> </path/to/track/dir>
|
||||||
#
|
#
|
||||||
# DEPENDENCIES src/gen_mtag
|
# DEPENDENCIES src/gen_mtag
|
||||||
#
|
#
|
||||||
# }
|
# }
|
||||||
|
|
||||||
import_dir() {
|
import_src() {
|
||||||
local GIT_DIR="${1}"
|
local GIT_DIR="${1}"
|
||||||
local TRACK_DIR="${2}"
|
local TRACK_DIR="${2}"
|
||||||
local SOURCE="${3}"
|
local SOURCE=$(basename "${2}")
|
||||||
|
local supportedsrcList=$(FLAC CUETOOLS EAC)
|
||||||
|
|
||||||
|
# Checks if source supported
|
||||||
|
if ! _if_array_contains ${SOURCE} ${supportedsrcList[@]}; then return 1; fi
|
||||||
|
|
||||||
|
|
||||||
local trackList=($(find ${TRACK_DIR} -maxdepth 1 -name '*.flac' -printf '%p\n' | sort))
|
local trackList=($(find ${TRACK_DIR} -maxdepth 1 -name '*.flac' -printf '%p\n' | sort))
|
||||||
|
|
||||||
# Join trackList
|
# Join trackList
|
||||||
_msg EXEC "Processing audio files"
|
echo "Processing audio files"
|
||||||
gen_image "${TRACK_DIR}/flac" $(printf "%s\t" ${trackList[@]}) > ${STDERR} 2>&1
|
gen_image "${TRACK_DIR}/flac" $(printf "%s\t" ${trackList[@]}) > ${STDERR} 2>&1
|
||||||
local EXIT="$?"
|
local EXIT="$?"
|
||||||
[[ $? -eq 0 ]] && _msg OK || { _msg WARN; return 1; }
|
[[ $? -eq 0 ]] || return 2
|
||||||
|
|
||||||
|
|
||||||
# Generates IMAGEID
|
# Generates IMAGEID
|
||||||
_msg EXEC "Generating IMAGEID"
|
echo "Generating IMAGEID"
|
||||||
[[ "${SOURCE}" == "CUETOOLS" ]] && local SOURCE=$(grep "CTDB TOCID:" ${TRACK_DIR}/accurip)
|
[[ "${SOURCE}" == "CUETOOLS" ]] && local SOURCE=$(grep "CTDB TOCID:" ${TRACK_DIR}/accurip)
|
||||||
local IMAGEID="SHA256-${SOURCE}--$(sha256sum "${TRACK_DIR}/flac" | cut -d' ' -f1)"
|
local IMAGEID="SHA256-${SOURCE}--$(sha256sum "${TRACK_DIR}/flac" | cut -d' ' -f1)"
|
||||||
_msg OK
|
|
||||||
|
|
||||||
# Generate metadata_trackList
|
# Generate metadata_trackList
|
||||||
|
echo "Generating metadata"
|
||||||
local COUNT=0
|
local COUNT=0
|
||||||
for track in ${trackList[@]}; do
|
for track in ${trackList[@]}; do
|
||||||
if [[ "${SOURCE}" == "FLAC" ]]; then
|
if [[ "${SOURCE}" == "FLAC" ]]; then
|
||||||
|
@ -47,17 +52,17 @@ import_dir() {
|
||||||
done
|
done
|
||||||
|
|
||||||
# Generate cuesheet
|
# Generate cuesheet
|
||||||
_msg EXEC "Generating cue file"
|
echo "Generating cue file"
|
||||||
gen_cue "${TRACK_DIR}" $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.cue"
|
gen_cue "${TRACK_DIR}" $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.cue"
|
||||||
local EXIT=$?
|
local EXIT=$?
|
||||||
[[ $? -eq 0 ]] && _msg OK || { _msg WARN; return 1; }
|
[[ $? -eq 0 ]] || return 3
|
||||||
add_bom "${GIT_DIR}/${IMAGEID}.cue"
|
add_bom "${GIT_DIR}/${IMAGEID}.cue"
|
||||||
|
|
||||||
# Generate tags file
|
# Generate tags file
|
||||||
_msg EXEC "Generating tags file"
|
_msg EXEC "Generating tags file"
|
||||||
gen_mtag $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.tags"
|
gen_mtag $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.tags"
|
||||||
local EXIT=$?
|
local EXIT=$?
|
||||||
[[ $? -eq 0 ]] && _msg OK || { _msg WARN; return 1; }
|
[[ $? -eq 0 ]] || return 4
|
||||||
add_bom "${GIT_DIR}/${IMAGEID}.tags"
|
add_bom "${GIT_DIR}/${IMAGEID}.tags"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue